I got a pile of data with coordinates last night. The coordinates were in State Plane NY West format, which is a semi-state specific coordinate system that needs to be translated before you can use it like latitude/longitude. There are better references out there if you want a thorough treatise on the subject, but I thought I’d give the concrete solutions I came up with in case you, like me, just want to get lat/lon and could hardly care less about 80’s era cartography.
Install proj4, the 80’s-era c library that everything relating to geospatial coordinate transformations seems to be built on. This is related to and possibly the basis for, but not actually the same thing as gdal. Gdal has some handy command-line tools in case you don’t need to do this programmatically. Further, it takes similar projection strings as proj4.
Anyway, build it from source. I had no trouble on Mac OS 10.6.
Install the ruby bindings. I had to build from source here (ruby 1.9.2) too- their build instructions were pretty handy. Just go through the configure/make/make install stuff, then rake as a gem, then gem install that local gem.
Code it up:
require 'proj4'
proj = Proj4::Projection.new '+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000 +y_0=0 +ellps=GRS80 +units=ft +no_defs'
geox = 1394144.401
geoy = 1165107.387
latlon = proj.inverse Proj4::Point.new(geox,geoy)
converter = (180 / Math::PI)
puts "lat = " + (latlon.lat * converter).to_s
puts "lon = " + (latlon.lon * converter).to_s
Note that geox and geoy are the inputs. The string of parameters in the call to Projection.new is what defines the initial projection (that is, the state plane) that the input is on. You’ll want to replace that with the one for your state. To get that info: