I started with How to convert shapefile coordinates? .
The answer there started me on [what I think] the right track, but I still could not solve my problem.
One of the problems is that I have not found the correct projection yet: https://gis.stackexchange.com/questions/13330/how-can-i-correctly-transform-unproject-from-lcc
EDIT: This question was answered on a gis site, and I was able to reproduce the correct conversion using the PROJ cs2cs command-line tool. It looks like this:
larry$ cs2cs -f "%.8f" +proj=lcc +lat_1=37.06666666666667 +lat_2=38.43333333333333 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000.0000000002 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs +to +proj=lonlat +datum=WGS84 +ellps=WGS84 6011287.4999795845 2100857.2499904726 -122.40375492 37.74919006 0.00000000
Now that I had the correct conversion, I was able to try the same thing in a simple way using RGeo:
ruby-1.9.2-p180 :001 > projection_str = ' +proj=lcc +lat_1=37.06666666666667 +lat_2=38.43333333333333 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000.0000000002 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs' => " +proj=lcc +lat_1=37.06666666666667 +lat_2=38.43333333333333 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000.0000000002 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs" ruby-1.9.2-p180 :002 > projection = RGeo::CoordSys::Proj4.new(projection_str) => #<RGeo::CoordSys::Proj4:0x805cba18 " +proj=lcc +lat_1=37.06666666666667 +lat_2=38.43333333333333 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000.0000000002 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs +towgs84=0,0,0"> ruby-1.9.2-p180 :003 > desired_str = '+proj=lonlat +datum=WGS84 +ellps=WGS84' => "+proj=lonlat +datum=WGS84 +ellps=WGS84" ruby-1.9.2-p180 :004 > desired = RGeo::CoordSys::Proj4.new(desired_str) => #<RGeo::CoordSys::Proj4:0x805271ac " +proj=lonlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"> ruby-1.9.2-p180 :005 > RGeo::CoordSys::Proj4::transform_coords(projection, desired, 6011287.4999795845, 2100857.2499904726 ) => [-140.92282523143973, 30.16981659183029]
- Why are the results different between RGeo and cs2cs?
- As soon as I can get RGeo to do the right translation, is there a way to create the right factory to convert the full geometry instead of a point?
- Is there a command line tool that I can use as a workaround to convert all points in my shapefile so that I can continue my life?
In general: Will someone please instruct me on how to use this library properly?
Thanks for watching.
ruby gis coordinates coordinate-systems proj
Larry
source share