Last active
August 29, 2015 14:25
-
-
Save danhammer/d915086cb9578f0e8e9f to your computer and use it in GitHub Desktop.
Demonstration of vegetation score extraction
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
# Sample code to demonstrate the vegetation extraction from satellite imagery. | |
# The example region is a small plot in the central valley: | |
# https://gist.github.com/danhammer/47590518ece27c2ef0ab | |
# Specifically, this reports the mean and standard deviation EVI score for all | |
# 30m pixels within the supplied polygon. To install the requests package on a | |
# Mac, type `sudo pip install requests` or visit this page for more comprehensive | |
# install instructions: | |
# http://docs.python-requests.org/en/latest/user/install/#install | |
import requests | |
def grabber(coords, begin, end): | |
base_url = 'http://wolak.enviro-service.appspot.com/vegetation/poly/series' | |
payload = dict(coords=coords, begin=begin, end=end) | |
r = requests.get(base_url, params=payload) | |
return r.json() | |
coords = str( | |
[ | |
[-120.38, 36.451], | |
[-120.38, 36.465], | |
[-120.36, 36.465], | |
[-120.36, 36.451], | |
[-120.38, 36.451] | |
] | |
) | |
data = grabber(coords, '2015-01-01', '2015-07-01') | |
print data['results'][0] | |
# >>> {u'date': u'2015-01-01T00:00:00', u'mean': 0.2486, u'stdev': 0.0979} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment