I have a series of shape files that I am trying to convert and enter into a postgis database so that I can pull the data out as GeoJSON but I am having troubles getting the data to enter with the correct coordinate values.

My source files say they are:

Datum:  NAD 83, CSRS98
Projection: UTM Extended Zone 13

And when I run gdalsrsinfo against the .prj file, I get the following:

PROJ.4 : '+proj=utm +zone=13 +ellps=GRS80 +units=m +no_defs '


Using that information, I pulled up http://georepository.com/crs_4140/NAD83-CSRS98.html and see the ID is listed at 4140.

So I ran

shp2pgsql -s 4140 shapefile > output.sql

But when I import the result into postgis, my coordinates are all out of sorts:

SELECT ST_AsGeoJSON(geom) FROM shapefile_import;

Can anyone point me in the right direction? I have been using http://geojsonlint.com to validate.

Edit 1

JGH's answer is correct, I was using the wrong ID in my conversion. It should have been 2151.

I ran now run SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) FROM shapefile_import;

  • what do you mean "out of sorts" those look like plausible UTM coordinates to me
    – Ian Turton
    May 28 '18 at 16:41
  • As documented AsGeoJSON postgis.org/docs/ST_AsGeoJSON.html creates old-school GeoJSON that supports different coordinate systems geojson.org/geojson-spec.html. You can validate such GeoJSON in another site geojson.io. However, your GeoJSON is missing the crs member and can't be reprojected right.
    – user30184
    May 28 '18 at 17:37
  • @user30184 is there a way to output an the "new" format in that case? I am looking to overlay these onto Google Maps API with addGeoJson which requires the inclusion of a Feature or FeatureCollection
    – mg87
    May 28 '18 at 17:41
  • It should be close to enough if you translate into epsg:4326 and omit crs member.
    – user30184
    May 28 '18 at 18:07
  • Correction: geojson.io can't be used for validating old school geojson. I have not found any site yet that does that.
    – user30184
    May 29 '18 at 5:07

The SRID 4140 is the wrong one, as it is in lat-long:

+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs

The SRID for the UTM zone you are looking for is 2151:

+proj=utm +zone=13 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
  • Aha, that makes sense. I am now able to perform a ST_AsGeonJSON(ST_Transform(geom, 4326)) to get my lnglat values.
    – mg87
    May 28 '18 at 17:37
  • @user30184 correct, typo.
    – mg87
    May 28 '18 at 17:40

Geojson linter uses wgs84 (EPSG:4326) wystem. Your is in 4140.

The coordinate reference system for all GeoJSON coordinates is a
geographic coordinate reference system, using the World Geodetic
System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units
of decimal degrees.

Your query should be

SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) FROM shapefile_import;

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.