Geoscience Reference
In-Depth Information
nation file, needs to be explicitly specified. For instance, to select all forest polygons
from the natural.shp dataset we can do:
ogr2ogr natural_forest.shp natural.shp -where 'type="forest"'
ogrinfo -so -al natural_forest.shp
Layer name: natural_forest
Geometry: Polygon
Feature Count: 7566
Extent: (1.393187, 48.113148) - (3.576257, 49.237916)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
osm_id: Real (11.0)
name: String (48.0)
type: String (16.0)
Whereas using -select , it is possible to create an output dataset that contains
a subset of attributes that have been specified:
ogr2ogr natural_select.shp natural.shp -select 'osm_id, name'
oginfo -so -al natural_select.shp
INFO: Open of 'natural_select.shp'
using driver 'ESRI Shapefile' successful.
Layer name: natural_select
Geometry: Polygon
Feature Count: 17259
Extent: (1.393187, 48.113148) - (3.576257, 49.237916)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
osm_id: Real (11.0)
name: String (48.0)
It is useful to note that both -select and -where can be combined within the
one command. For instance, we could merge the above examples to select a subset
of all of the forest polygons from the natural.shp and output a subset of the
attributes.
ogr2ogr natural_select_subset.shp natural.shp -select 'osm_id,
name' -where 'type="forest"'
oginfo -so -al natural_select_subset.shp
INFO: Open of 'natural_select_subset.shp'
using driver 'ESRI Shapefile' successful.
Layer name: natural_select_subset
 
 
Search WWH ::




Custom Search