Geoscience Reference
In-Depth Information
places
points
railways
roads
waterways.
It is quite common to either download vector spatial data from the Internet or to
receive a dataset that is not in the Spatial Reference System (SRS) that you require
for your particular purposes. As a result, it is necessary to reproject the dataset into
another SRS. For instance, you may want to reproject an OSM dataset that is pro-
jected to the WGS84 (EPSG:4326) projection to the Spherical Mercator projection
(EPSG:3857), which is used byWebmapping services like GoogleMaps. The codes 4
are read by GDAL/OGR and provide a succinct way of specifying the Spatial Refer-
ence System. The following example demonstrates how to convert the multipolygons
within the OSM dataset using ogr2ogr .
ogr2ogr
-s_srs "EPSG:4326"-t_srs"EPSG:3857"
ile-de-france-latest_3857.osm.pbf
ile-de-france-latest.osm.pbf multipolygons
2.4.1 Manipulating Data
Both ogrinfo and ogr2ogr provide a very useful SQL (Structured Query Lan-
guage) interface, which permits the use of SQL statements on the command line
to create subsets of datasets defined by SQL queries. GDAL 1.8.0 saw the biggest
improvement in terms of the SQL support, with older versions not supporting arith-
metic and field expressions. The following examples will demonstrate how both
ogrinfo and ogr2ogr can be used with the SQL filter. For instance, to query a
specific field in a vector dataset we can first use ogrinfo to list the fields and then
run an SQL expression on one or more of the fields. In the following example, we
use ogrinfo to identify the unique types of natural classes. We start by retrieving
the attributes of the 'natural' features from the ESRI Shapefile version of the OSM
d ataset.
ogrinfo -so -al natural.shp
osm_id: Real (11.0)
name: String (48.0)
type: String (16.0)
We then use ogrinfo to return the list of unique types of features labelled as
“natural” using the following SQL statement.
4 http://epsg.io/
 
 
Search WWH ::




Custom Search