1

I create a shapefile using this ogr2ogr command:

ogr2ogr -f "ESRI Shapefile" -overwrite -a_srs EPSG:28992 -explodecollections \
-makevalid "Clipped.shp" "org.shp" -clipsrc "border.shp"

Because of -a_srs a .prj file is also created. When I look at https://epsg.io/28992 I can see the content of this .prj file is in ESRI WKT.
When I open this file in Surfer I get a warning the projection cannot be read.
When I replace the content of the .prj-file with the OGC WKT version, Surfer has no problems opening this file.
I assume ogr2ogr uses the ESRI WKT format because I set the format to ESRI Shapefile.

I tried adding --config OSR_WKT_FORMAT for all options (SFSQL WKT1_SIMPLE WKT1 WKT1_GDAL WKT1_ESRI WKT2_2015 WKT2_2018 WKT2 DEFAULT) but the .prj-file is always the same.

How do I instruct ogr2ogr to create the .prj file in OGC WKT format?

3
  • don't save to a shapefile if you don't want an ESRI prj file
    – Ian Turton
    Commented Jul 21, 2023 at 15:53
  • Thanks Ian for your response, but creating a shapefile is mandatory. --config OSR_WKT_FORMAT suggests you can change it. But how?
    – Paul Meems
    Commented Jul 21, 2023 at 16:53
  • I think it's specified in the Shapefile spec so you can't over ride it for that format
    – Ian Turton
    Commented Jul 21, 2023 at 17:13

1 Answer 1

1

Maybe a valid shapefile should use ESRI style .prj file because after all it is an ESRI format. But you obviously need a workaround so I suggest converting .prj by using the gdalsrsinfo utility https://gdal.org/programs/gdalsrsinfo.html.

Example:

Use the ESRI style input

test.prj
========
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

gdalsrsinfo -o WKT2 test.prj

GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]],
        ID["EPSG",6326]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["Degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["longitude",east,
            ORDER[1],
            ANGLEUNIT["Degree",0.0174532925199433]],
        AXIS["latitude",north,
            ORDER[2],
            ANGLEUNIT["Degree",0.0174532925199433]]]
1
  • I tried it and it works! I use it like this: gdalsrsinfo -o WKT1 EPSG:28992 > my.prj I've marked your reply as the answer.
    – Paul Meems
    Commented Jul 28, 2023 at 14:09

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.