This class handles a single API request to the Google Static Street View APIĪpi_key: obtain it from your Google Cloud Platform console Import requests import json import matplotlib.pyplot as plt import matplotlib.image as mpimg class StreetViewer ( object ): def _init_ ( self, api_key, location, size = "640圆40", folder_directory = './streetviews/', verbose = True ): """ Throughout this notebook, I will be using the powerful Python package requests to fulfill the requests I send to the API service. In this section, I will be testing the Street View API with a valid address, just to showcase the expected results from requests. If you would rather skip the mechanism around Metadata, using this package will be an easier option than writing your own codes for the API. However, I did not find the option to interact with the Metadata as precreening as described above. There is an open-source Python package google_streetview available for direct Python usage.In other words, using the metadata requests to pre-screen any of your street view request will save you from paying for invalid request where no street view is available. If your street view request will return available street view picture, this status field will have the value "OK". The metadata includes a field called status.The metadata request is free of charge! You can access the documentation of the metadata request here. You also have the possibility to request the image metadata from the API without requesting the actual street view picture.The parameters of the API can be found here Be sure to check the pricing before doing your queries. Google’s API policies, including the pricing policy, are known to be changing over time.The cost of each request for a static Street View panorama is around 0.007 USD - 0.0056 USD at the time this post is published (May, 2020).Follow this official guidance to obtain your API key In order to query the API, you will need to register your own Google Cloud Platform account, enable billing for your project, and create a Google API key for the Street View API.Key Facts about the Street View Static API (as of May 2020)īefore we get started on the codes, I am listing some of the key specs about the street view API that’s important when querying the service. In this post, I will walk you through how I created a Python class for accesss the street view API. Although it’s a paid service, being able to query the service with large batches enables us to create our own image-based modeling dataset. The Google Street View Static API is Google’s straightforward HTTP-based API for developers to access its massive collection of street view pictures. How to Query Google Street View Static API with Python (UPDATED IN 2020)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |