Database Reference
In-Depth Information
Tip
For Windows users
The script uses the
grep
and
awk
Linux commands, so you will need
todownloadtheirWindowsversionsfrom
http://unxutils.sourceforge.net/
.
There's thechancethatyoualreadyhavetheminstalledinyoursystem
if you have installed OSGeo4W—a binary distribution of a broad set of
open-source, geospatial software for Win32 environments. You can find
it at
http://trac.osgeo.org/osgeo4w/
.
Note
You could eventually skip the creation of the
rivers_clipped_by_country
view and perform the query in the
ogr2ogr
statement in the script, as shown in the following command
(
ogr2ogr
passes the content of the
-sql
option directly to PostGIS):
ogr2ogr rivers/rivers_$f.shp
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" -sql "SELECT
r.name, c.iso2,
ST_Intersection(r.the_geom, c.the_geom)
AS the_geom FROM chp03.countries AS c
JOIN chp03.rivers AS r ON
ST_Intersects(r.the_geom, c.the_geom)
WHERE c.iso2 = '$f'"
4. Now,runthefollowingscript(inLinux,youneedtoassign
execute
permis-
sions to the script beforehand):
$ chmod 775 rivers.sh
$ ./export_rivers.sh