[gdal-dev] reading features without loading geometries
Milton Jonathan
milton at tecgraf.puc-rio.br
Wed May 7 13:50:57 EDT 2008
Hello Frank
Thanks a lot for your quick answer! I guess that approach will do in
practice, since large data will usually be in a RDBMS. Actually, I also
thought about this, but I didn't have a spatial database at hand (I did
test it on a shapefile, but as you said in that case the driver loads
the geometry anyway..)
Well, another similar thing that I was trying to do was to just load the
Envelope of each object without loading the whole geometry. Do you think
that would be possible with OGR? The reason for doing this is to quickly
scan all the objects' bounding boxes in order to build a spatial tree
for caching purposes. It would be great if we could do that!
Thanks again
Milton
Frank Warmerdam wrote:
> 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,
More information about the gdal-dev
mailing list