Copernicus
Visualizing Copernicus data interactively with Leafmap
To learn more about Copernicus data, please visit https://dataspace.copernicus.eu.
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# %pip install -U leafmap localtileserver
# %pip install -U leafmap localtileserver
In [ ]:
Copied!
import os
import rasterio
import leafmap.maplibregl as leafmap
import os
import rasterio
import leafmap.maplibregl as leafmap
To use Copernicus data, you need to get your own credentials. Follow the instructions here to get the credentials. Then, replace the os.environ["AWS_ACCESS_KEY_ID"] and os.environ["AWS_SECRET_ACCESS_KEY"] with your own credentials.
In [ ]:
Copied!
os.environ["AWS_ACCESS_KEY_ID"] = "YOUR_ACCESS_KEY_ID"
os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR_SECRET_ACCESS_KEY"
os.environ["AWS_S3_ENDPOINT"] = "eodata.dataspace.copernicus.eu"
os.environ["AWS_VIRTUAL_HOSTING"] = "FALSE"
os.environ["GDAL_HTTP_UNSAFESSL"] = "YES"
os.environ["AWS_HTTPS"] = "YES"
os.environ["GDAL_HTTP_TCP_KEEPALIVE"] = "YES"
os.environ["AWS_ACCESS_KEY_ID"] = "YOUR_ACCESS_KEY_ID"
os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR_SECRET_ACCESS_KEY"
os.environ["AWS_S3_ENDPOINT"] = "eodata.dataspace.copernicus.eu"
os.environ["AWS_VIRTUAL_HOSTING"] = "FALSE"
os.environ["GDAL_HTTP_UNSAFESSL"] = "YES"
os.environ["AWS_HTTPS"] = "YES"
os.environ["GDAL_HTTP_TCP_KEEPALIVE"] = "YES"
You can create a ~/.s3cfg file to store the credentials. Then use the following command to list the data.
s3cmd -c .s3cfg ls s3://eodata/
Let's try out the sample dataset of global water bodies.
In [ ]:
Copied!
url = "/vsis3/eodata/CLMS/bio-geophysical/water_bodies/wb_global_1km_10daily_v2/2018/01/01/c_gls_WB_201801010000_GLOBE_PROBAV_V2.1.1_cog/c_gls_WB-WB_201801010000_GLOBE_PROBAV_V2.1.1.tiff"
url = "/vsis3/eodata/CLMS/bio-geophysical/water_bodies/wb_global_1km_10daily_v2/2018/01/01/c_gls_WB_201801010000_GLOBE_PROBAV_V2.1.1_cog/c_gls_WB-WB_201801010000_GLOBE_PROBAV_V2.1.1.tiff"
In [ ]:
Copied!
with rasterio.open(url) as src:
print(src.profile)
with rasterio.open(url) as src:
print(src.profile)
Visualize the water bodies interactively with Leafmap.
In [ ]:
Copied!
m = leafmap.Map(projection="globe")
m.add_basemap("Esri.WorldImagery", visible=False)
m.add_raster(url, vmin=1, vmax=100, colormap="Blues", layer_name="Water Bodies")
m
m = leafmap.Map(projection="globe")
m.add_basemap("Esri.WorldImagery", visible=False)
m.add_raster(url, vmin=1, vmax=100, colormap="Blues", layer_name="Water Bodies")
m