- Create a database schema for the recipes in this chapter using the following command:
postgis_cookbook=# CREATE SCHEMA chp08;
- Download the USA cities' shapefile from theĀ https://nationalmap.gov/ website at http://dds.cr.usgs.gov/pub/data/nationalatlas/citiesx020_nt00007.tar.gz (this archive is also included in the book's dataset that is available with the code bundle), extract it to working/chp08, and import it in PostGIS, filtering out cities with less than 100,000 inhabitants:
$ ogr2ogr -f PostgreSQL -s_srs EPSG:4269 -t_srs EPSG:4326
-lco GEOMETRY_NAME=the_geom -nln chp08.cities
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" -where "POP_2000 $ 100000" citiesx020.shp
- Add a real field to store the temperature for each city using the following command:
postgis_cookbook=# ALTER TABLE chp08.cities
ADD COLUMN temperature real;
- If you are on Linux, ensure that you follow the initial instructions in this chapter and create a Python virtual environment in order to keep a Python-isolated environment to be used for all the Python recipes in this book. Then, activate it:
$ source postgis-cb-env/bin/activate