I have a data file exported from an ARCGIS system (parcel data from local government). Its a zip file containing 7 files: f.dbf, f.prj, f.sbn, f.sbx, f.shp, f.shp.xml, f.shx.

I have a simple ruby script that uses the rgeo and rgeo/shapefile gem to read the .shp file and extract points. The points don't look like lat, long eg.

936934.017177403 695547.1331697404 

I would like to convert the points to lat longs that I can upload to google maps or similar.

I think the solution involves reading the .prj and .shp file, then telling the tool to project into EPSG:3867.

Is there a simple script or commandline tool that handles conversions like this. eg:

convert f.shp f.prj -EPSG:3857 > new.shp

I would prefer to use a ruby / rgeo solution. But anything unixy that can be scripted would work.

  • Is this a polygon or point layer? – GISKid Jun 28 '16 at 22:40
  • There are 100K records, from what I can tell all MULTIPOLYGON. – Patrick Cullen Jun 28 '16 at 23:11

That is a trivial task with gdal:

 ogr2ogr -t_srs EPSG:3857 destination.shp source.shp

See http://www.gdal.org/ogr2ogr.html for more information.

There might be ruby bindings for this, I have no idea.

EPSG:3857 coordinates are not lat/long though, if you really need those, just use EPSG:4326.

  • Does ogr2ogr reads the .prj file implicitly? – Patrick Cullen Jun 29 '16 at 17:55
  • The args are reversed, should be ogr2ogr -t_srs EPSG:3857 new.shp old.shp. – Patrick Cullen Jun 29 '16 at 17:58
  • Oops, fixed. Yes, for GDAL/OGR the .prj file is just part of the Shapefile. – bugmenot123 Jun 30 '16 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.