[gdal-dev] reading features without loading geometries

Frank Warmerdam warmerdam at pobox.com
Wed May 7 13:06:11 EDT 2008


Milton Jonathan wrote:
> Dear all,
> 
> I would like to know if there would be a standard mechanism in OGR for 
> reading features without loading their geometries (e.g., for efficiently 
> building a list of features from which to choose from, even for layers 
> with a large number of features with significantly sized geometries)
> 
> I suppose that some drivers may not able to do it (e.g., drivers for 
> simple file formats), but for database drivers that should be simple.

Milton,

One approach to this is to execute a custom query using ExecuteSQL().


eg.

OGRLayer *poResult = datasource->ExecuteSQL(
       "SELECT FID from ROADS where class in (\"M1\",\"M2\")" );

This would give back features with only the attribute FID matching the query.
When the backend is a real RDBMS this would generally be done efficiently
without touching the geometries.  For flat formats like Shapefiles the
machinery still reads the whole features to execute the query, so it would
not be particularly fast.


Best regards,
-- 
---------------------------------------+--------------------------------------
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    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list