Skip to content

Instantly share code, notes, and snippets.

@vincentsarago
Created February 17, 2020 21:18
Show Gist options
  • Save vincentsarago/98cff96fe40fba87711904a26f9256eb to your computer and use it in GitHub Desktop.
Save vincentsarago/98cff96fe40fba87711904a26f9256eb to your computer and use it in GitHub Desktop.
# Please be kind
# See https://github.com/developmentseed/awspds-mosaic
# to deploy your own
endpoint = "https://landsatlive.live"
# Define AOI here
bounds = [-5.833740234375, 46.15700496290803, -0.9118652343749999, 49.23912083246698]
# Date Filters
start = "2019-01-01T00:00:00Z"
end = "2019-12-31T23:59:59Z"
# SAT-API QUERY
# see http://sat-utils.github.io/sat-api/
query = {
"bbox": bounds,
"time": f"{start}/{end}",
"query": {
"eo:sun_elevation": {"gt": 0},
"landsat:tier": {"eq": "T1"},
"collection": {"eq": "landsat-8-l1"},
"eo:cloud_cover": {"gte": 0, "lt": 3}, # Cloud Filters
},
"sort": [{"field": "eo:cloud_cover", "direction": "asc"}],
}
tilescale = 2 # Each tile will be 512x512px
tilesize = 256 * tilescale
# We post the query to the mosaic endpoint with some optional parameters
results = requests.post(
f"{endpoint}/mosaic/create",
json=query,
params={
# Landsat covers zoom 7 to 12 but
# because we don't want to use the mosaic for visualization
# purpose we don't really care about lower zoom level.
# We could use zoom 11 but don't want to make the mosaicJSON file too big.
# Minzoom define the quadkey zoom and thus the number of quadkey list
# See https://github.com/developmentseed/mosaicjson-spec/tree/master/0.0.2
"minzoom": 9,
# We filter the season to have greenest data
"seasons": "spring,summer",
# Here we can also pass some tile option to be added to the tile url.
"tile_format": "tif", # We use GeoTIFF output from the tiler
"tile_scale": tilescale,
},
).json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment