Database Reference
In-Depth Information
3. Import all of those layers in a PostGIS table named chp03.earthquakes
simultaneouslybyexecutingoneofthefollowingscripts,usingthe ogr2ogr
command.
The following is the Linux version (name it import_eq.sh ):
#!/bin/bash
for ((i = 1; i < 9 ; i++)) ; do
echo "Importing earthquakes with
magnitude $i to chp03.earthquakes PostGIS
table..."
ogr2ogr -append -f PostgreSQL -nln
chp03.earthquakes
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'"
2012_Earthquakes_ALL.kml -sql "SELECT
name, description, CAST($i AS integer) AS
magnitude FROM 'Magnitude $i'"
done
The following is the Windows version (name it import_eq.bat ):
@echo off
for /l %%i in (1, 1, 9) do (
echo "Importing earthquakes with
magnitude %%i to chp03.earthquakes
PostGIS table..."
ogr2ogr -append -f PostgreSQL -nln
chp03.earthquakes
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'"
2012_Earthquakes_ALL.kml -sql "SELECT
name, description, CAST(%%i AS integer)
AS magnitude FROM 'Magnitude %%i'"
)
4. Execute the following script (for Linux, you need to add execute permis-
sions to it):
Search WWH ::




Custom Search