We will need to create three tables to hold the crime data. We need a table for:
- Area commands
- Beats
- Incidents
To create the tables, we need to import the required libraries:
import psycopg2import requestsfrom shapely.geometry import Point,Polygon,MultiPolygon, mappingimport datetime
The precious code imports psycopg2 for connecting to PostGIS, requests to make the call to the service so you can grab the data, Point, Polygon, and MultiPolygon from shapely.geometry to make converting the GeoJSON to objects easier, and datetime because the incidents have a date field.
In Chapter 3, Introduction to Geospatial Databases, you created a database named pythonspatial with a user called postgres. We will create the tables in ...