Created
October 25, 2013 19:51
-
-
Save danhammer/7160839 to your computer and use it in GitHub Desktop.
A very quick example of how to construct the query that will eventually be linked to on the country pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def construct_query(iso, fmt = 'shp'): | |
# Builds the API call to download FORMA in various formats Other | |
# acceptable formats are 'csv', 'GeoJSON', 'JSON', 'kml', or 'svg' | |
base = "http://wri-01.cartodb.com/api/v2" | |
var = "x,y,date_array" | |
sql = "SELECT %s FROM gfw2_forma WHERE iso = '{%s}'" % (var, iso) | |
query = "%s/sql?format=%s&q=%s" % (base, fmt, sql) | |
# return the result. do something with it, depending on format. | |
return requests.get(query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment