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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.