[gdal-dev] Getting actual path to a layer

Even Rouault even.rouault at spatialys.com
Tue Jun 11 00:32:02 PDT 2019

On lundi 10 juin 2019 22:47:11 CEST David Strip wrote:
> The docs say that the return value of GetName()
> should be sufficient to open the data source if passed to the same
> OGRSFDriver that this data source was opened with, but it need not be
> exactly the same string that was used to open the data source.

You are refering here it to OGRDataSource::GetName(), whereas Nyall was 
refering to OGRLayer::GetName()

> My question is -- GetName() here returns just the file base name (i.e.
> "lines" for "/path/lines.shp"). Is there anyway to retrieve the actual
> layer file path for these?

No, for most formats, there is no direct mapping from a layer to file(s) 
containing layer data, so there is nothing in the OGR API for that. So you 
have to use the knowledge that this is opened by the shapefile or mapinfo + 
that the datasource name is a directory, and then you can form a filename from 
that and the layer name.


Spatialys - Geospatial professional services

More information about the gdal-dev mailing list