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"}}}'
                        )
                    )
                )
2
  • Your solution only works if the crs is already listed in spatial_ref_sys table. ST_Transform(geom,25832) would be the same.
    – AndreJ
    Commented Apr 7, 2014 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
    Commented Apr 7, 2014 at 17:08

1 Answer 1

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.

3
  • 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
    Commented Apr 7, 2014 at 12:40
  • @thegrouch -- It's also best if you edit the new requirements/info (user inputs CRS) into the question.
    – Martin F
    Commented Apr 7, 2014 at 17:11
  • Is it a recommended way to add support for new CRS definitions - adding them manually to spatial_ref_sys table?
    – jayarjo
    Commented Nov 8, 2020 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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