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

Adding data to the table

In the previous section, we created a table. In this section, you will grab data from an open data site and put it on your table so that you can query it in the next section.

Most cities have open data websites and portals. The City of Albuquerque has several ArcServer endpoints with spatial data. The following code will use the requests Python library to grab public art data and then use psycopg2 to send it to the PostgreSQL database, pythonspatial:

import requestsurl='http://coagisweb.cabq.gov/arcgis/rest/services/public/PublicArt/MapServer/0/query'params={"where":"1=1","outFields":"*","outSR":"4326","f":"json"}r=requests.get(url,params=params)data=r.json()data["features"][0]

The code which we mentioned earlier ...

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