ESRI shapefiles include a .prj file containing CRS information in Well-Known Text (WKT) format. I'm developing a software in which I need to systematically read shapefiles' CRS information, convert it to a Proj4 string, and feed Proj4 with it.

The software I'm developing can not have dependencies on GDAL.

So, how can I systematically convert/parse a WKT string from a .prj file into a Proj4 string? Is there any direct mapping between the tags?

Alternatively, instead of converting to a Proj4 string, finding the corresponding EPSG code would also be acceptable.

  • The .prj file isn't strictly in WKT format, so you might be specifying a wrong source. – Vince May 25 '17 at 17:42
  • Can't you take the morphtoesri part of GDAL into your software? That is the part that makes the conversion and it is MIT licensed. – user30184 May 25 '17 at 18:41
  • Somehow use spatialreference.org and/or ask the site creators if they used something other than GDAL or PROJ4 itself. – mkennedy May 25 '17 at 19:53
  • @Vince What other formats can it have? I have never seen (or heard of) a .prj file that wasn't in WKT. But I also haven't found any clear specifications... – jmds May 26 '17 at 8:23
  • @user30184 This may be the solution, however the morphFromESRI function converts the WKT text to a gdal internal format which I'm not familiar with. I was looking for a more straightforward conversion to Proj4. But I may have to resort to some kind of reverse engineering of that function, though. PS: I think you meant morphFromESRI :) – jmds May 26 '17 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.