How to do it...

The steps you need to follow to complete this recipe are as follows:

  1. Unzip the wborders.zip archive to your working directory. You can find this archive in the book's dataset.
  2. Import the world countries shapefile (wborders.shp) in PostGIS using the ogr2ogr command. Using some of the options from ogr2ogr, you will import only the features from SUBREGION=2 (Africa), and the ISO2 and NAME attributes, and rename the feature class to africa_countries:
      $ ogr2ogr -f PostgreSQL -sql "SELECT ISO2,       NAME AS country_name FROM wborders WHERE REGION=2" -nlt       MULTIPOLYGON PG:"dbname='postgis_cookbook' user='me'      password='mypassword'" -nln africa_countries       -lco SCHEMA=chp01 -lco GEOMETRY_NAME=the_geom wborders.shp
  1. Check if the shapefile ...

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.