GPS Coords -> Map Placement

Topics: SharpMap Project, SharpMap v0.9 / v1.x
Jun 25, 2010 at 1:19 PM
Edited Jul 1, 2010 at 5:18 PM

Hey SharpMap forums,

I'm new to mapping and have found myself a little stuck in my development.
I'm building a simple GPS system that shows the driver where they are on some set routes we've defined via ShapeFiles.
I've been displaying a shapefile that contains all the roads in the area this GPS is for.
Now, I want to add a layer that consists of just one point and has a symbol for your current location.
The GPS attached to this device returns lat and lng, using the WGS84 coordinate system.
I'm at the point where I'm ready to add the layer, but am unsure of how to properly transform the lat/lng that comes back from the GPS into the map's projection/coordinate system.

So my questions are:

1) What are the basic steps for adding a shapefile (with .prj projection file) and a point from live GPS coordinates to display correctly on the map?

2) What's the difference between a projection and a coordinate system?

3) Will every layer I put on the map require a CoordinateTransformation?  If so, how do you determine what source/target system to transform it to (from the CoordinateTransformationFactory.CreateFromCoordinateSystems() method)?  If it's a shape file, the source is defined by the projection file - but if it's a SharpMap.Geometry?

4) I also place SharpMap.Geometries on the map (Point, Linestring); will I ever need to set it's SpacialReference (ICoordinateSystem) to display it correctly?  If you change the Geometry's SpacialReference, do you still need a CoordinateTransformation on the layer?

I think once I've wrapped my head around this whole conversion process I should be able to figure the rest out...
Thanks for any help!


Jun 27, 2010 at 9:43 PM

Hello IntelligentRebo,

1) My suggestion would be:

  • Choose the desired spatial reference for your application, preferably a projected one, since distance and area calculations are easier.
  • Set up CoordinateTransformation for every layer which spatial data does not come in that spatial reference.
  • Create some provider for your livefeed gps data. Maybe this could be of any help.

2.) Please read this excellent post.

3.) Every layer that does not have the desired spatial reference needs an apropriate coordinate transfromation.

4.) You don't have to set spatial references or set up coordinate transformations if your coordinates are in the desired spatial reference.

Hth FObermaier

Jul 1, 2010 at 5:25 PM
FObermaier, Thank you very much for your response! That article was a big help - I obviously just needed a crash course in coordinate/projection systems. I had mistakenly assumed that a shape file was drawn in coordinates that weren't directly related to real world lat/lng coordinates. The easiest thing for me to do in this case was to draw the background map (shapefile) in it's native coordinates and then transform the lat/lng coming back from the GPS in WGS84. Gave the program a test run this morning and it looked great. Thanks again for all your help. Rebo PS - As an aside, when would you ever need to set the SpacialReference of a point? And wouldn't that do the same as putting a CoordinateTransformation on the layer it is a part of?