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

Christy Nieman cnieman at dmsolutions.ca
Fri Mar 25 09:46:54 EDT 2011


Sorry, wrong order for the source and destination files.  Should be 
output.shp then input.shp

C

On 03/25/2011 09:45 AM, Christy Nieman wrote:
> Hello,
>
> You can indeed use both -select and -where together together.  For 
> example
>
> ogr2ogr -select field1,field2,field3 -where "field1 = value OR field2 
> = anotherValue" input.shp output.shp
>
> Best regards,
> Christy
>
> On 03/25/2011 09:38 AM, Luiz Motta wrote:
>> 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
>> _______________________________________________
>> 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