[gdal-dev] How do I open vector files (e.g. shp) using GDAL

Frank Warmerdam warmerdam at pobox.com
Mon Jul 20 17:12:12 EDT 2009


Smart, Gary wrote:
> I understand that GDAL can open vector formats as if they were a dataset?
> 
>  
> 
> E.g. I read that it is possible to pass the GDALOpen either a single 
> .shp file (in which case it treats it as if it only had one layer) or a 
> directory containing multiple .shp files – which presumably it opens as 
> multi layered?
> 
>  
> 
> However, whenever I try to open vector files in this way (directory or 
> file) I get…
> 
>  
> 
> ERROR 4  - blah blah is not recognised as a supported file format”

Gary,

The GDAL library can open vector files, but it is not accomplished with
GDALOpen().  Instead you need to call OGROpen(), and use the OGR API
for vector (feature) datasets.

   http://www.gdal.org/ogr

Good luck,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
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