Created
December 24, 2017 18:20
-
-
Save paulopperman/0dccbb26442b3ded7d77ae05a5fcefbb to your computer and use it in GitHub Desktop.
Basic Google Street View Imagery API calls
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 | |
from PIL import Image | |
from io import BytesIO | |
import json | |
url = 'https://maps.googleapis.com/maps/api/streetview' | |
key = STREETVIEW_API_KEY | |
out_file = 'streetviewimg.jpg' | |
# Get an image | |
params = { | |
"location":'Newport, RI', # this can be lat/lon | |
'size':"600x400", | |
'key': key, | |
} | |
resp = requests.get(url, params=params, stream=True) | |
img = Image.open(BytesIO(resp.content)) | |
img.save(out_file,'jpeg') | |
# Get metadata | |
params = {'location': 'Newport, RI', 'key':key} | |
met = requests.get(url + '/metadata', params=params) | |
data = json.loads(met.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment