Database Reference
In-Depth Information
Tip
If you get the output as ERROR: function getsrid(geometry)
does not exist LINE 1: SELECT getsrid("the_geom") FROM
(SELECT,... , you will need to load the legacy support in PostGIS, for
example, in a Debian Linux box:
psql -d postgis_cookbook -f /usr/share/
postgresql/9.1/contrib/postgis-2.1/
legacy.sql
5. If you are using Windows, create a batch file named ex-
port_shapefiles.bat , that iterates each record (country) in the
hs_countries.csv fileandgeneratesashapefile withthecorresponding
hotspots exported from PostGIS for that country:
@echo off
for /f "tokens=1-3 delims=, skip=1" %%a
in (hs_countries.csv) do (
echo "Generating shapefile %%b.shp
for country %%a (%%b) containing %%c
features"
ogr2ogr out_shapefiles/%%b.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
ONST_Contains(c.the_geom,
ST_Transform(hs.the_geom, 4326)) WHERE
c.iso2 = '%%b'"
)
6. Runthebatchfileaftercreatinganoutputdirectory( out_shapefiles )for
the shapefiles that will be generated by the script:
Search WWH ::




Custom Search