single image test
This commit is contained in:
@@ -1,3 +1,2 @@
|
|||||||
GEODB_USER=xxx
|
CDSE_S3_ACCESS_KEY=xxxx
|
||||||
GEODB_PW=xxx
|
CDSE_S3_SECRET_KEY=xxxx
|
||||||
GEODB_NAME=xxx
|
|
||||||
56
app/main.py
56
app/main.py
@@ -4,9 +4,65 @@ import time
|
|||||||
import pystac_client
|
import pystac_client
|
||||||
import geogif
|
import geogif
|
||||||
import stackstac
|
import stackstac
|
||||||
|
from matplotlib import pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("starting app.")
|
print("starting app.")
|
||||||
|
|
||||||
|
URL = "https://stac.dataspace.copernicus.eu/v1"
|
||||||
|
cat = pystac_client.Client.open(URL)
|
||||||
|
cat.add_conforms_to("ITEM_SEARCH")
|
||||||
|
|
||||||
|
geom = {
|
||||||
|
"type": "Polygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[32.6, -17.3],
|
||||||
|
[32.6, -17.1],
|
||||||
|
[33.0, -17.1],
|
||||||
|
[33.0, -17.3],
|
||||||
|
[32.6, -17.3],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"max_items": 1,
|
||||||
|
"collections": "sentinel-2-l2a",
|
||||||
|
"datetime": "2017-02-01/2017-10-01",
|
||||||
|
"intersects": geom,
|
||||||
|
"query": {"eo:cloud_cover": {"gte": 0, "lte": 20}},
|
||||||
|
"sortby": "properties.eo:cloud_cover",
|
||||||
|
"fields": {"exclude": ["geometry"]},
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Searching items...")
|
||||||
|
items = list(cat.search(**params).items_as_dicts())
|
||||||
|
print("Search successful.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
stack = stackstac.stack(
|
||||||
|
items=items,
|
||||||
|
resolution=(60, 60),
|
||||||
|
bounds_latlon=(33.0, -17.1, 32.6, -17.3),
|
||||||
|
chunksize=98304,
|
||||||
|
epsg=32634,
|
||||||
|
gdal_env=stackstac.DEFAULT_GDAL_ENV.updated(
|
||||||
|
{
|
||||||
|
"GDAL_NUM_THREADS": -1,
|
||||||
|
"GDAL_HTTP_UNSAFESSL": "YES",
|
||||||
|
"GDAL_HTTP_TCP_KEEPALIVE": "YES",
|
||||||
|
"AWS_VIRTUAL_HOSTING": "FALSE",
|
||||||
|
"AWS_HTTPS": "YES",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
rgb = stack.sel(band=["B04_60m", "B03_60m", "B02_60m"])
|
||||||
|
print(rgb)
|
||||||
|
rgb.plot()
|
||||||
|
plt.show()
|
||||||
@@ -3,7 +3,16 @@ services:
|
|||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
container_name: copernicus-app
|
container_name: copernicus-app
|
||||||
|
volumes:
|
||||||
|
- ./app:/app
|
||||||
environment:
|
environment:
|
||||||
PYTHONUNBUFFERED: 1
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
GDAL_HTTP_TCP_KEEPALIVE: YES
|
||||||
|
AWS_S3_ENDPOINT: odata.dataspace.copernicus.eu
|
||||||
|
AWS_ACCESS_KEY_ID: ${CDSE_S3_ACCESS_KEY}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${CDSE_S3_SECRET_KEY}
|
||||||
|
AWS_HTTPS: YES
|
||||||
|
AWS_VIRTUAL_HOSTING: FALSE
|
||||||
|
GDAL_HTTP_UNSAFESSL: YES
|
||||||
|
|
||||||
Reference in New Issue
Block a user