[gdal-dev] Selecting features using ogrinfo

Even Rouault even.rouault at mines-paris.org
Thu Mar 1 19:29:45 EST 2012


Le vendredi 02 mars 2012 01:03:07, David J. Bakeman a écrit :
> kungphil wrote:
> > Hi
> > 
> > I want to select a feature from a shapefile and extract the extent to
> > then clip a raster.  I thought I could use ogrinfo to select an
> > individual feature but using the command below the reported extent is
> > for the whole shapefile.
> > 
> > ogrinfo -al -where GRID_ID=312 shapefile.shp
> 
> First what version of gdal and what OS are you running on?
> 
> I ran this on one of my shapefiles I'm running gdal 1.7.3 on linux
> fedora core 14 and got just the matching feature back:
> 
> ogrinfo -al -where 'POLYID=5' polys.shp

Phil is mentionning the spatial extent I believe, not the exactness of the 
features returned.

Yes, ogrinfo on shapefiles will always report the full layer extent, even if 
you put an attribute filter. A way to solve your problem is to produce a 
temporary shapefile with ogr2ogr and the attribute filter, and ask the extent on 
it.

> 
> > Help please!
> > 
> > Phil
> > 
> > --
> > View this message in context:
> > http://osgeo-org.1560.n6.nabble.com/Selecting-features-using-ogrinfo-tp4
> > 537990p4537990.html Sent from the GDAL - Dev mailing list archive at
> > Nabble.com.
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list