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 database

Generating the database table is made possible by the Chapter12_0.py script, which creates a PostgreSQL database called chapter12 and adds spatial functionality to the new database. Adjust the credentials, host, and port (as needed) in the connection configuration below.

Connect to the database server using psycopg2 and its connect function, which creates a connection class. The class has a cursor function that creates a cursor object, which is able to execute SQL statements. This section creates the database for the chapter:

import psycopg2connection = psycopg2.connect(host='localhost', user='{user}',password='{password}', port="5432")connection.autocommit = Truecursor = connection.cursor()cursor.execute('CREATE DATABASE ...
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