We are seeing .prj files from our users that don't look like the normal WKT formatted ones we've seen up to this point, instead, they match the format illustrated at "Esri Grid format". When we attempt to use these files in GeoTools, it fails to parse these prj files - it expects them to be WKT.

An example that looks like NZ Transverse Mercator looks like this:

Projection    TRANSVERSE
Datum         AI_NZGD00
Spheroid      GRS80
Units         METERS
Zunits        NO
Xshift        0.0
Yshift        0.0
0.9996 /* scale factor at central meridian
 173  0  0.0 /* longitude of central meridian
   0  0  0.0 /* latitude of origin
1600000.0 /* false easting (meters)
10000000.0 /* false northing (meters)

A quick look through some GDAL source says that these might be 'old style .prj files' from Arc/Info version 7 - but maybe they're still being proliferated for some reason? Is there an option in newer versions of Arc to output the old version?

Or maybe there's some GeoTools code that can read these files, or a way to get gdal to convert them?

UPDATE I started trying to port the gdal code to use with GeoTools, but it looked like a total headache. I've ended up using GDAL JNI to parse the prj file with a kludgy but workable solution. The importFromESRI method doesn't look usable as it seems to want a pointer to some text, so instead I create an almost empty ascii grid and create a sidecar prj file containing the esri prj data I want to parse. I do this like so:

  public CoordinateReferenceSystem parsePrj(String prjContents) {
    try {
      // prepare an asc file with the prj sidecar filled with the prj data to parse
      File asc = File.createTempFile("dummy", ".asc");
      File prj = Paths.get(asc.getParent(), Files.getNameWithoutExtension(asc.getName()) + ".prj").toFile();
      Files.write(dummyAscContents.getBytes(), asc);
      Files.write(prjContents.getBytes(), prj);

      // We can't get at `SpatialReference_ImportFromESRI(long, SpatialReference, Vector)` directly, but it'll be used
      // when opening a bitmap dataset - so we open a tiny dataset with a prj file loaded with the required contents...
      Dataset dummyDataset = gdal.Open(asc.getAbsolutePath(), gdalconstConstants.GF_Read);

      if (dummyDataset == null) {
        // not an expected user facing error, no need for i18n
        throw new RuntimeException("GDAL configuration error - could not open dummy asc");
      // ... so we get get the wkt out from here
      String wkt = dummyDataset.GetProjection();

      if (Strings.isNullOrEmpty(wkt)) {
        throw new RuntimeException("could not parse prj - " + prjContents, e);

      return CRS.parseWKT(wkt);

    } catch (Exception e) {
  • Another question came up and linked to svn.osgeo.org/gdal/trunk/autotest/osr/osr_esri.py - the test cases here seem to imply GDAL supports these prj files - We're using GeoTools, which attempts to parse the contents as WKT, which unsurprisingly fails Mar 26, 2020 at 9:22
  • 1
    Why not use gdal_translate and make a geotiff from your files? That should embed the projection info into the geotiff Apr 1, 2020 at 2:26
  • @KurtSchwehr this isn't a one off job, this is so that users don't have to do a conversion when using the software we're building. Thanks though :) Apr 5, 2020 at 23:35
  • If it is an openly documented format then you could either write the code yourself or contract a GeoTools expert to do it for you docs.geotools.org/latest/userguide/welcome/support.html
    – Ian Turton
    Jun 22, 2020 at 7:52

1 Answer 1


Unfortuantely .prj files are how the coordinate system/projection information is stored for few different formats used by current ESRI products, particular flat file based information. There doesn't seem to be native tools within ArcMap to create a WKT format of the .prj file. I have had some experience in defining WKT files for custom coord systems, (for defining inside of Geoserver) and I can attest that this is a very temperamental process, depending upon the coord system itself and how its defined. Because not all the systems require all parameters, or sometimes they define different parameters based on reference datums, or other reference systems, it was quite a process.

Some more information can be found in this article below, which may help with your code. How are ESRI WKT projections different from OGC WKT projections?

  • Thanks - Arc WKT is supported in geotools, it's the flat file (non wkt) version that isn't. I can't find a reference to the standard anywhere, either - the only trace or mention of it is in the links in the original question. Jun 23, 2020 at 3:46
  • try Wikipedia to read up on it, to begin with en.wikipedia.org/wiki/… then you can read about wkt as implimeted as an ogc standard here ogc.org/standards/ct (see link to pdf on that page. its pretty heavy reading though.)…. my only advice would be to see if you can find on the web existing wkt definitions, and copy from there.
    – nr_aus
    Jun 23, 2020 at 6:49

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.