Python tool to extract a bounding box of a given radius around a center location (longitude, latitude) using the Planet Tiles API.
The bounding box is projected onto longitude and latitude using the World Geodetic System 1984 WGS84. The Planet Tiles API is indexed using Spherical Mercator Projection.
Images are prepared and processed as follows:
-
Prepare URLs by filling templates from Planet Tiles API with the corresponding tiles. A bounding box may lie on 1, 2, or 4 tiles.
-
The image data is downloaded from the URLs.
-
If the bounding box lies on more than one tile, these tiles are stitched together to form one image.
-
Calculate the bounds of the bounding box within the stitched image.
-
Crop the bounding box from the stitched image.
We wrote a blog post with more details about the foundational concepts behind the API. You find it here.
-
PIL
-
urllib
-
mercantile
-
numpy
git clone https://github.com/V-AI-S/planet-box-extractor.git
cd planet-box-extractor
pip install --upgrade build
pip build .
pip install .
from planet_box_extractor import PlanetBoxExtractor
radius = 0.2
zoom = 15
map_id = '' # can be found in the Planet Explorer
API_KEY = '' # can be found in the user account
extractor = PlanetBoxExtractor(radius, zoom, map_id, API_KEY)
image = extractor.Process(latitude, longitude)
Browse the API documentation here.