[gdal-dev] ESRI and .prj
Frank Warmerdam
warmerdam at p...
Thu Aug 23 09:03:08 EDT 2001
Ben Discoe wrote:
>
> So, i implemented some .prj files by using GDAL like this:
>
> // write
> FILE *fp2 = fopen(prj_name, "wb");
> char *wkt;
> m_proj.exportToWkt(&wkt);
> fputs(wkt, fp2);
> OGRFree(wkt);
> // read
> FILE *fp2 = fopen(prj_name, "rb");
> char wkt_buf[2000], *wkt = wkt_buf;
> fgets(wkt, 2000, fp2);
> m_proj.importFromWkt((char **) &wkt);
>
> Works fine for reading/writing my own data. Does it seem like using
> OGRSpatialReference's Wkt methods in this way will be
> compatible/interchangable with what ESRI is doing? I don't follow
> everything in their explanation below, but it sound like they distinguish
> three different things:
>
> 1. "classic" "old-style" ESRI .prj
> 2. "original" OpenGIS WKT
> 3. "newer" OpenGIS WKT, influenced by more usage of EPSG/POSC by ESRI
>
> I'd guess GDAL implementats something between #2 and #3, possible compatible
> with software expecting either?
Ben,
A few issues. Some OGRSpatialReference's may includes "newer" style WKT
definitions like AUTHORITY and AXIS. These may not be supported by ESRI
though I would hope they would ignore them. The exportToPrettyWkt()
method includes a "simplify" option which essentially strips off this
newer cruft. Perhaps I should add a method on the OGRSpatialReference
that would strip all newer information, converting to "original" WKT.
However, in general I am hoping that ESRI will track the evolution of
the WKT format.
Second, you should probably put a newline at the end of the line in the
.prj file, so "fprintf( fp2, "%s\n", wkt );" might be more appropriate.
Best regards,
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list