1

I am new in PostGIS and I am trying to convert a geometry field to GeoJSON Lat/Lng for visualization in a map as a layer.

I had a .HSP file that I exported to PostGIS with OpenJump program.

The .prj of .shp is:

PROJCS["ETRS_1989_UTM_Zone_30N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-3.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

For get the SRID I searched in: https://developers.arcgis.com/javascript/3/jshelp/gcs.html and I got the 4258 code.

But when I execute:

ST_AsGeoJSON(ST_Transform(ST_SetSRID(geo,4258),4326))

I get:

"{"type":"Polygon","coordinates":[[[526196.6063,4744503.4952],[526155.287,4744194.9938],[526067.3464,4744213.9994],[526088.0997,4744354.9984],[526109.542,4744513.4959],[526196.6063,4744503.4952]]]}"...

Which is not a Lat/Lng correct value.

What could be wrong?

  • 2
    Your code is EPSG:25830 spatialreference.org/ref/epsg/etrs89-utm-zone-30n. OpenJUMP can save directly into GeoJSON, though it is creating GeoJSON according to the year 2008 specification. – user30184 Nov 29 '18 at 13:01
  • @user30184 can you post that as the answer please? Since it seems to have worked for the asker. In PostGIS it would just be: ST_AsGeoJSON(ST_Transform(ST_SetSRID(geo,25830),4326)) – HeikkiVesanto Nov 29 '18 at 14:13
3

You selected wrong help page that handles geographic coordinate systems. What you have is a projected system (PROJCS) and from the page about projected coordinate systems https://developers.arcgis.com/javascript/3/jshelp/pcs.html you can find that the code "25830" stands for ETRS_1989_UTM_Zone_30N

25830 ETRS_1989_UTM_Zone_30N

PROJCS["ETRS_1989_UTM_Zone_30N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-3.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

OpenJUMP can also save data directly into GeoJSON but it supports only the original 2008 version of the specification http://geojson.org/geojson-spec.html.

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.