Skip to Content
Mastering Geospatial Analysis with Python
book

Mastering Geospatial Analysis with Python

by Silas Toms, Paul Crickard, Eric van Rees
April 2018
Beginner to intermediate content levelBeginner to intermediate
440 pages
11h 36m
English
Packt Publishing
Content preview from Mastering Geospatial Analysis with Python

Creating the tables

We will need to create three tables to hold the crime data. We need a table for:

  1. Area commands
  2. Beats
  3. 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 3Introduction to Geospatial Databases, you created a database named pythonspatial with a user called postgres. We will create the tables in ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Geospatial Analysis with Python

Learning Geospatial Analysis with Python

Joel Lawhead

Publisher Resources

ISBN: 9781788293334Supplemental Content