[GRASS-dev] [GRASS GIS] #2456: read CSV from GDAL data directory
Even Rouault
even.rouault at spatialys.com
Mon Apr 25 13:12:40 PDT 2016
Le lundi 25 avril 2016 22:02:20, Paul Kelly a écrit :
> Hi Markus, Even,
>
> On 04/24/2016 10:29 PM, Markus Neteler wrote:
> > Hi Paul,
> >
> > you are probably the person with most insights into lib/proj/convert.c.
> >
> > I try to debug why the North Carolina Location cannot be generated
> >
> > properly (EPSG 3358) but comes out like this:
> > grass71 -c epsg:3358 ~/grassdata/nc_data
> > GRASS 7.1.svn (nc_data):~ > g.proj -w
> > PROJCS["NAD83(HARN) / North Carolina",
> >
> > GEOGCS["grs80",
> >
> > DATUM["unknown",
>
> The datum name "unknown" is coming through from GDAL. Here is a simple
> test program to illustrate it (using latest SVN GDAL from this evening):
>
> #include <stdio.h>
> #include <ogr_srs_api.h>
>
> main()
> {
> OGRSpatialReferenceH hSRS;
> const char *datum;
>
> hSRS = OSRNewSpatialReference(NULL);
> OSRImportFromProj4(hSRS, "+init=epsg:3358");
>
> datum = OSRGetAttrValue(hSRS, "DATUM", 0);
> printf("Datum name is %s\n", datum);
>
> return 0;
> }
>
> Compile as:
> gcc -Wall -o test test.c -lgdal
> and run:
> ./test
> Datum name is unknown
>
>
> Perhaps there is a better / more correct way to get the co-ordinate
> system definition from GDAL than by requesting it as a "+init=epsg:XXXX"
> PROJ string?
Yes, if you use OSRImportFromProj4(), the building of the SRS WKT will be done
by "reverse engineering" the proj.4 string that gets expended by proj.4 from
+init=epsg:3358 to "+proj=lcc +lat_1=36.16666666666666
+lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0
+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs". Which has lost any
datum name.
The solution is simple : use OSRImportFromEPSG(hSRS, code)
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the grass-dev
mailing list