[Xastir] Datum conversions

Tom Russo russo at bogodyn.org
Sun Dec 19 02:42:12 EST 2004


On Sun, Dec 19, 2004 at 12:04:19AM -0700, we recorded a bogon-computron collision of the <jewen at shaw.ca> flavor, containing:
> Okay, now you get to drag me around another learning curve.
>  
> I got ahold of a bunch of shapefiles for an area where we will be using APRS
> to track assets for an upcoming cross-country ski race in February.
>  
> I stuffed them into my map directory, and found that I could not see them.
> After a little head scratching, I finally figured out that the datum might
> be wrong. shpinfo show me file bounds of 1369668.166, 923382.659 /
> 1386313.311, 934944.981

What you really mean is that they're in some projection other than lat/lon.

> I would guess that this might be UTM values, but don't know how to determine
> that for sure.

The best and most certain way to determine it is to look for a file that
came with the shapefiles that might tell you --- for example, if you have
a set of shapefiles that just happen to have an extra file with a ".prj"
extension you might be in luck.  Depending on what program produced the .prj
"ogr2ogr" might be able to read it directly.

Barring that, you need to go to the source for certain.

> The area in question is at about 53.5N, 112.8W.

Unfortunately, the numbers you show above don't look like they're UTM
coordinates for the area you're saying they represent.  Longitude 112W is
right at the boundary of UTM zone 12, and if I try to convert 112.8W, 53.5N
to UTM in zone 12 with cs2cs (from the proj4 install) I get 
380607.21Easting,5929401.53Northing --- nothing like the numbers you show
above.  So I can't even begin to guess what projection is used (could be
just about anything).

> Reading Tom's tutorial, it looks like I have to be able to tell the
> conversion program what datum it starts in, and what datum I'd like it to
> end up in.

Projection, yes.  You need to know what projection it's in, and you need
to convert that to "unprojected" latitude/longitude.  Without information
about what projection the shapefile is in, it's just a bunch of lines in
an unspecified coordinate system.

> I would guess that there's no info encoded into the file to determine what
> datum is used, otherwise the conversion program would only need to know the
> desired output format.

No, one of the problems with shapefiles is they have no way of storing
the projection and datum information.  The only way to get this information
is through auxilliary files, called "metadata".  If you have a .prj file
that has contents that look like the cryptic stuff I describe on my shape_web
page, then ogr2ogr can read it.  Sometimes there's a .txt file or html file
that comes with the shapefiles to describe what's in them.  Otherwise you
have to go to the source and hunt it down.  If you downloaded the shapefiles
from a web site, go to that web site and see if they have some metadata 
describing the shapefiles.

If you have a shapefile that is just one polyline, it would not be too 
difficult to write a small program that converts it into a file that one of 
the GPS upload utilities uses.  At the moment, xastir has no capability to 
load anything *into* a GPS through gpsman, only download stuff from one.

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 http://www.qsl.net/~km5vy/
 "When life gives you lemons, find someone with a paper cut."



More information about the Xastir mailing list