Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#2861 closed enhancement (wontfix)

ogr2ogr, -fid and value list

Reported by: peifer Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: 1.6.0
Severity: normal Keywords:


I am trying to get 20 out of 200 features from 1 shape file into 1 KML file. I am currently doing this via creating a second shp file with the 20 wanted features (via a bash loop with a lot of -append and -update) and then create the KML from the temporary shp file.

It would be more helpful if I could specify a value list for the fid parameter.

Something like: ogr2ogr -fid "0,5,9,125,155"


Change History (2)

comment:1 by Even Rouault, 15 years ago

Resolution: wontfix
Status: newclosed

You can already do that by using the -where option (or the -sql as well) and the fact that the fid is a special SQL field (see

ogr2ogr dest.shp source.shp -where "fid in (0,5,9,125,155)"


ogr2ogr dest.shp source.shp -sql "select * from source_layer where fid in (0,5,9,125,155)"

You could also make more powerful requests (like -where "(fid >= 5 and fid <= 127) or fid = 456"), so I'm wondering if it's worth extending the -fid capability. In fact, it could just be removed if we wouldn't care about backwards compatibility...

I've added the above hint in the manual of ogrinfo and ogr2ogr in r16429.

in reply to:  1 comment:2 by peifer, 15 years ago

Thanks for the hint. Somehow, I came to the obvious wrong conclusion that -sql and -where are only relevant in the context of connecting to some MySQL, PostgreSQL, PostGIS, etc. data sources. Sorry for overlooking how helpful these options are in general.

Note: See TracTickets for help on using tickets.