[gdal-dev] OGR2OGR options -select and -where together

Luiz Motta motta.luiz at gmail.com
Fri Mar 25 09:38:01 EDT 2011


Devs,

I would like have the subset of data, by filters of field (-select)
and attributes(-where), using OGR2OGR.

My enviroment is:
- Windows XP
- GDAL from OSGEO4W
- Version: GDAL 1.8.0, released 2011/01/12

At the moment, i can only make subset(field and attribute) by call
separate of OGR2OGR.

Has one manner to use options  "select" and "where" in the same call OGR2OGR  ?

Next, my tests  to make subsets:

1) Source data:
http://www.dpi.inpe.br/prodesdigital/dadosn/2009/PDigital2009_23367_shp.zip

2) Show info:
2.1) Summary
ogrinfo -so Prodes2009_23367.shp Prodes2009_23367
2.2) Subset features (see -where)
ogrinfo -q -geom=NO -where "ano = '2009' and class_name =
'DESFLORESTAMENTO'"  Prodes2009_23367.shp Prodes2009_23367 | more

3) Subset data

3.1) Filter by field(-select) and attribute(-where) -> Empty data output
ogr2ogr -f "ESRI Shapefile" -select "ano" -where "ano = '2009' and
class_name = 'DESFLORESTAMENTO'" filter_select_where.shp
Prodes2009_23367.shp
ogrinfo -so filter_select_where.shp filter_select_where
* Feature Count = 0

3.2) Filter by field(-select)
ogr2ogr -f "ESRI Shapefile" -select "ano" filter_select.shp
Prodes2009_23367.shp
ogrinfo -so filter_select.shp filter_select

3.3) Filter by attribute(-where)
ogr2ogr -f "ESRI Shapefile" -where "ano = '2009' and class_name =
'DESFLORESTAMENTO'" filter_where.shp Prodes2009_23367.shp
ogrinfo -so filter_where.shp filter_where

Regards,
Luiz Motta


More information about the gdal-dev mailing list