Database Reference
In-Depth Information
hs_countries.csv fileandgeneratesashapefile withthecorresponding
hotspots exported from PostGIS for that country:
#!/bin/bash
while IFS="," read country iso2 hs_count
do
echo "Generating shapefile $iso2.shp
for country $country ($iso2) containing
$hs_count features."
ogr2ogr out_shapefiles/$iso2.shp
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" -lco SCHEMA=chp01
-sql "SELECT ST_Transform(hs.the_geom,
4326), hs.acq_date, hs.acq_time,
hs.bright_t31 FROM
chp01.hotspots as hs JOIN chp01.countries
as c ON
ST_Contains(c.the_geom,
ST_Transform(hs.the_geom, 4326)) WHERE
c.iso2 = '$iso2'"
done < hs_countries.csv
4. Giveexecutionpermissionstothebashfile,andthenrunitaftercreatingan
outputdirectory( out_shapefiles )fortheshapefilesthatwillbegenerated
by the script. Then, go to step 7:
chmod 775 export_shapefiles.sh
mkdir out_shapefiles
$ ./export_shapefiles.sh
Generating shapefile AL.shp for country
Albania (AL) containing 66 features.
Generating shapefile DZ.shp for country
Algeria (DZ) containing 361 features.
...
Generating shapefile ZM.shp for country
Zambia (ZM) containing 1575 features.
Generating shapefile ZW.shp for country
Zimbabwe (ZW) containing 179 features.
Search WWH ::




Custom Search