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

Buffer

A spatial database allows you to store spatial data, but you can also perform operations on the data and get different geometries back. The most common of these operations would be a buffer. You have a table of points, but using ST_Buffer(), you can have the database return a polygon around the point with a specified radius. The following code shows you how:

cursor.execute("SELECT ST_AsText(ST_Buffer(a.location,25.00,'quad_segs=2')) from pieces a WHERE a.code='101'")cursor.fetchall()

The previous code grabs a record from the table where the art code field equals 101, and selects a buffer with a radius of 25 around the location. The result will be a polygon, which is shown as follows:

When using geography, if the buffer is large, falls ...
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