Giter Site home page Giter Site logo

lin102 / streetview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robolyst/streetview

0.0 0.0 0.0 114.57 MB

Python package for retrieving current and historical photos from Google Street View

Shell 0.12% Python 8.99% Makefile 0.47% Jupyter Notebook 90.42%

streetview's Introduction

streetview

This is a light module for downloading photos from Google street view. The functions allow you to retrieve current and old photos. Google does have an API for accessing Street View. However, it does not allow you to access old photos. Their javascript API allows you to download segments of current photos. This API also allows you to download each full panorama as you see it on Google Street View.

Please note, Google does not maintain the access points used by this API for public use. Therefore, this hack may break if Google makes changes to how Street View works.

Install

Install from pip with:

pip install streetview

Quick start

Search for Panoramas

The photos on Google street view are panoramas. Each parnorama has its own unique ID. Retrieving photos is a two step process. First, you must translate GPS coordinates into panorama IDs. The following code retrieves a list of the closest panoramas:

from streetview import search_panoramas

panos = search_panoramas(lat=41.8982208, lon=12.4764804)
first = panos[0]

print(first)
# pano_id='_R1mwpMkiqa2p0zp48EBJg' lat=41.89820676786453 lon=12.47644220919742 heading=0.8815613985061646 pitch=89.001953125 roll=0.1744659692049026 date='2019-08'

Get Metadata

Not all panoramas will have a date field in the search results. You can fetch a date for any valid panorama from the metadata api:

from streetview import get_panorama_meta

meta = get_panorama_meta(pano_id='_R1mwpMkiqa2p0zp48EBJg', api_key=GOOGLE_MAPS_API_KEY)

print(meta)
# date='2019-08' location=Location(lat=41.89820659475458, lng=12.47644649615282) pano_id='_R1mwpMkiqa2p0zp48EBJg'

Download streetview image

You can then use the panorama ids to download streetview images:

from streetview import get_streetview

image = get_streetview(
    pano_id="z80QZ1_QgCbYwj7RrmlS0Q",
    api_key=GOOGLE_MAPS_API_KEY,
)

image.save("image.jpg", "jpeg")

Download panorama

You can download a full panorama like this:

from streetview import get_panorama

image = get_panorama(pano_id="z80QZ1_QgCbYwj7RrmlS0Q")

image.save("image.jpg", "jpeg")

Development

Run tests with:

make test

this will install mamba and the required Python packages into a local env.

If you want to rebuild VCR cassettes, you will need to copy .env-example to .env and add your Google Maps API Key.

streetview's People

Contributors

robolyst avatar azarz avatar rodrigoberriel avatar theturehooha avatar matanabudy avatar sysuin avatar miliasv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.