[gdal-dev] EPSG code not recognized from GeoTiff written by GDAL

Roger Bivand roger.bivand at nhh.no
Sat May 28 02:02:49 PDT 2016


Blumentrath, Stefan <Stefan.Blumentrath <at> nina.no> writes:

> 
> Hi,
> 
> And thanks Even and Jukka for your answers!
> 
> Based on the info you provided I investigated a bit more and it seems to
be an issue "downstreams" indeed.
> 
> gdalsrsinfo epsg:25832 gave the same result for me than for Jukka (the
result from listgeo further down,
> just for the record).
> 
> In GRASS GIS 7.0.4 and 7.1.svn, g.proj -w gave me the projection
information as in the GeoTIFF, though
> without any AUTHORITY parameters (as it is supposed to according to the
manual). The AUTHORITY tags seem
> to be added by r.out.gdal, except for the authority parameter for the
entire projection... Even if g.proj
> -g returns epsg=25832...
> 
> gdal_translate -a_srs EPSG:25832 in.tif out.tif adds the AUTHORITY
parameter to the GeoTIFF, while
> gdal_edit -a_srs EPSG:25832 does not.
> 

One route to writing from R (from a SpatialGridDataFrame or another object
coerced to that class) is:

SEXP
RGDAL_SetProject(SEXP sxpDataset, SEXP proj4string) {

  OGRSpatialReference oSRS;
  char *pszSRS_WKT = NULL;

  GDALDataset *pDataset = getGDALDatasetPtr(sxpDataset);

  installErrorHandler();
  oSRS.importFromProj4(CHAR(STRING_ELT(proj4string, 0)));
  oSRS.exportToWkt( &pszSRS_WKT );
  uninstallErrorHandlerAndTriggerError();

  installErrorHandler();
  OGRErr err = pDataset->SetProjection(pszSRS_WKT);
  CPLFree( pszSRS_WKT );

  if (err == CE_Failure) 
	warning("Failed to set projection\n");
  uninstallErrorHandlerAndTriggerError();

  return(sxpDataset);
}

It is as you see going from a proj4 string (used in Spatial objects to hold
the CRS/SRS) to WKT. Could this be re-written to provide the Authority, or
is Authority unrepresented in proj4?

Best wishes

Roger


> Kind regards,
> Stefan 
> 





More information about the gdal-dev mailing list