GithubHelp home page GithubHelp logo

andolg / satellite-imagery-downloader Goto Github PK

View Code? Open in Web Editor NEW
52.0 3.0 11.0 19.07 MB

A Python program for downloading satellite imagery by geographic coordinates

License: MIT License

Python 100.00%
google-maps maps mercator python requests

satellite-imagery-downloader's Introduction

Satellite Imagery Downloader

A Python program that downloads a rectangular map region by its geographic coordinates and saves it as a PNG image. It works by downloading map tiles at a given zoom level and cropping border tiles to fit the region.

This program should work with any raster map that uses Web Mercator, including Google Maps, Esri and OpenStreetMap.

© 2023 Google

Usage

Please note that downloading map tiles without using the API may violate the map service's terms of use.

Make sure you have Python 3 installed.

Install the required packages.

pip install -r requirements.txt

Run main.py.

On the first run, the program will create a preferences file next to main.py. Run the program again. Now you will be asked to enter the coordinates and zoom level in the command line.

  • Enter the coordinates of the top-left and bottom-right corners of a rectangular region as decimal degrees (latitude before longitude) with any separator you want, e.g. 40.612123, -73.895381.

  • Enter the zoom level at which you want to get the image. This article explains how it affects the scale and resolution.

Google Maps satellite imagery will be used by default.

Preferences file

  • "url" is the URL template that the program will use to download map tiles.
  • "tile_size" is the size of a single tile in pixels. The default is 256.
  • "channels" determines how tiles will be decoded as well as the number of channels in the final image. The default is 3. Use 4 for transparent tiles, such as in roads-only layers.
  • "dir" is the directory where your images will be saved. If the directory doesn't exist, it will be created automatically.
  • "headers" are the headers that the program will use to make HTTP requests.

Optional:

preferences.json can also be used to specify the coordinates and zoom level. If you leave one of the following fields empty, you will be asked to use the command line instead.

  • "tl" and "br" are the coordinates of the top-left and bottom-right corners of a rectangular region.
  • "zoom" is the zoom level.

If you encounter any problems with the program, feel free to open an issue.

Tile URL

Here are some tile URLs that you can use:

If you need to download an image from a different map service, you can try to get the tile URL using your browser. Open the map, then open developer tools (Ctrl+Shift+I) and go to the Network panel. When you refresh the page or scroll the map, it logs the resources that are being downloaded. Find a tile, copy the URL and replace its coordinate and zoom values with {x}, {y} and {z}.


Examples

Images in full resolution: https://mega.nz/folder/7sxTwALS#n2bFCYk9JsiU7nbVQH-ntw

© 2022 Google

© 2022 Google

© 2022 Google

© 2023 Google

© OpenStreetMap

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.