Ticket #2861 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 4 years ago

ogr2ogr, -fid and value list

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

Description

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"

Hermann

Change History

follow-up: ↓ 2   Changed 4 years ago by rouault

  • status changed from new to closed
  • resolution set to wontfix

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  http://gdal.org/ogr/ogr_sql.html)

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

or

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   Changed 4 years ago by peifer

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.