Geography Reference
In-Depth Information
population: Real (11.0)
OGRFeature(cities_subset):0
capital (String) = N
country (String) = US
name (String) = Seward
population (Real) = 2699
POINT (-149.449996948241989 60.119998931884801)
OGRFeature(cities_subset):1
capital (String) = N
country (String) = US
name (String) = Anchorage
population (Real) = 184300
POINT (-149.172973632811988 61.188648223877003)
The cities layer in PostGIS has 606 features. You can see that our spatial
subset has two features, both contained within the latitude/longitude
rectangle we specified. Notice that the extent of the new layer is less
than what we specified as the spatial boundaries. The bounding rect-
angle is specified as xmin, ymin to xmax, ymax—in this case -152, 58
to -148, 62. The extent of the new layer is smaller, because it repre-
sents the extent of the features extracted, not the search rectangle. You
can probably think of ways in which creating subsets by attributes or
spatial boundaries can come in handy.
A recent addition to the OGR utilities is support for KML. This allows
you to export an OGR supported data source to KML for use in Google
Earth. 4
$
ogr2ogr -f KML volcanoes.kml "PG:dbname=gis_data host=madison" volcanoes
Depending on your version of GDAL/OGR, if you try to use ogrinfo on
volcanoes.kml , you will get an error message. Preliminary support for
reading KML files is not available in GDAL prior to version 1.5.
Coordinate System Conversion
We can also change the coordinate system of a layer using ogr2ogr .
You can do this even if you don't want to change the format of the
layer. For our cities.shp we created earlier, we could convert it from WGS
84 (latitude/longitude) to some other coordinate system, such as U.S.
National Atlas Equal Area. To do this, we need to know either the pro-
jection parameters or the EPSG code. As we saw in Chapter 9 , Projec-
tions and Coordinate Systems, on page 138 , there are a number of ways
Be aware that Google Earth expects your KML to be in geographic coordinates.
4.
 
 
 
Search WWH ::




Custom Search