April 2018
Beginner to intermediate
440 pages
11h 36m
English
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 ...