2

How do i transform a geometry to a new geometry with a crs like urn:ogc:def:crs:EPSG::25832

st_transform(geom,integer srid) obviously doesn't work since my srid is a string

found a solution

ST_Transform(geom,
             ST_SRID(
                     ST_GeomFromGeoJSON(
                       '{"type":"POINT",
                         "coordinates":[0,0],
                         "crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::25832"}}}'
                        )
                    )
                )
  • Your solution only works if the crs is already listed in spatial_ref_sys table. ST_Transform(geom,25832) would be the same. – AndreJ Apr 7 '14 at 14:43
  • 1
    Welcome to GIS.SE. It's good to solve your own problems, and best for all of us if you post the solution as an Answer, not in the Q. – Martin F Apr 7 '14 at 17:08
1

You have to enter the CRS definition into the spatial_ref_sys table of postgis, giving it a unique SRID. Then you can use that in all functions.

Usually, all EPSG codes are already in there.

  • thx but im developing a REST service to transform geometrys and since the crs is a user input i dont want to add a bunch of custom crs definitions – thegrouch Apr 7 '14 at 12:40
  • @thegrouch -- It's also best if you edit the new requirements/info (user inputs CRS) into the question. – Martin F Apr 7 '14 at 17:11

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.