How to do it...

If you did not follow the recipes in Chapter 1, Moving Data in and out of PostGIS, be sure to import the hotspots (Global_24h.csv) in PostGIS. The following steps explain how to do it with ogr2ogr (you should import the dataset in their original SRID, 4326, to make spatial operations faster):

  1. Start a session in the postgis_cookbook database:
      > psql -d postgis_cookbook -U me
  1. Create a new schema chp10 in the postgis_cookbook database:
      postgis_cookbook=# CREATE SCHEMA chp10;
  1. We need to create the hotspots_dist table, that will serve as parent for the foreign tables:
      postgis_cookbook =# CREATE TABLE chp10.hotspots_dist (id serial       PRIMARY KEY, the_geom public.geometry(Point,4326));
  1. Exit the psql environment:
 postgis_cookbook=# ...

Get PostGIS Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.