Skip to content

Instantly share code, notes, and snippets.

@paulopperman
Created December 24, 2017 18:20
Show Gist options
  • Save paulopperman/0dccbb26442b3ded7d77ae05a5fcefbb to your computer and use it in GitHub Desktop.
Save paulopperman/0dccbb26442b3ded7d77ae05a5fcefbb to your computer and use it in GitHub Desktop.
Basic Google Street View Imagery API calls
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