5

I need to provide WKTs of spatial reference systems in the APIs provided by GDAL/OGR.

Is there some specific place where I can look for WKTs of the spatial reference systems that I'm working with? Or is there some method/property in the SpatialReference class etc through which I can find the WKTs of different spatial reference systems?


Meta-info for people from non-geography/Computer Science background: All the three answers currently given below are good. I accepted the answer that let my code be self managed. I didn't have to hard-code the strings in my program and used the API itself. Also, beware of the harmless sound of "Well Known String". It sounds as if it's very small and easy to remember thing.

7

GDAL has methods for that. From http://www.gdal.org/classOGRSpatialReference.html: "contains methods for converting between this object organization and well known text (WKT) format".

ExportToWkt is probably what you need

"Convert this SRS into WKT format. Note that the returned WKT string should be freed with OGRFree() or CPLFree() when no longer needed. It is the responsibility of the caller. This method is the same as the C function OSRExportToWkt().

http://www.gdal.org/classOGRSpatialReference.html#a596b8e527d66a5054408159f0006fdac

There is also a GDAL utility program http://www.gdal.org/gdalsrsinfo.html

Usage example:

gdalsrsinfo  -o wkt epsg:4326

GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
5

I usually look at http://epsg.io or http://spatialreference.org for all my WKT needs.

  • 1
    epsg.io is under active development, and has a good Web API and source code is available. Spatialreference.org is pretty much abandoned since 2013 and is out of sync with updates to spatial reference changes and corrections. – Mike T Apr 26 '16 at 3:23
1

Have you tried:

projected coordinate systems: https://developers.arcgis.com/javascript/jshelp/pcs.html

geographic coordinate systems: https://developers.arcgis.com/javascript/jshelp/gcs.html

  • Thanks for the link. I went through both of them before but sadly the issue was that I didn't know that a "Well Known Text" would be so long! I was looking for a small string like "3857" or "EPSG:3857" kind of thing. But WKTs are surprisingly long. – displayName Apr 25 '16 at 18:50
  • To others stumbling over this question: the links provided in this answer take you directly to the WKTs. In the other answers you will have to provide some more info to get the WKT but in this one you can simply search in your browser and copy the the WKT for your use. – displayName Apr 26 '16 at 1:48
  • These are also "Esri" WKT versions. We have some quirky names and parameters that may not be understood by other software packages. Note: I work at Esri on coordinate systems, etc. – mkennedy Apr 26 '16 at 20:27

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.