from shapely.geometry import shape
geometry = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-28.615951538085938,
38.53836423409098
],
[
-28.619985580444336,
38.525002928341095
],
[
-28.606510162353516,
38.51949654282164
],
[
-28.598356246948242,
38.543063600957204
],
[
-28.615951538085938,
38.53836423409098
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-28.547630310058594,
38.55138743998161
],
[
-28.548316955566406,
38.53420168131867
],
[
-28.53252410888672,
38.54064682206034
],
[
-28.531150817871094,
38.55246141354153
],
[
-28.547630310058594,
38.55138743998161
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-28.198728561401367,
38.67525826307041
],
[
-28.210229873657227,
38.67592834040206
],
[
-28.2169246673584,
38.66520635037862
],
[
-28.195466995239258,
38.66641265441879
],
[
-28.198728561401367,
38.67525826307041
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-27.203006744384766,
38.649857708475814
],
[
-27.21691131591797,
38.64757859040289
],
[
-27.214336395263672,
38.637656878877266
],
[
-27.203693389892578,
38.642215673667934
],
[
-27.203006744384766,
38.649857708475814
]
]
]
}
}
]
}
import openeo
c = openeo.connect("openeo-dev.vito.be")
c.authenticate_oidc()
Authenticated using refresh token.
<Connection to 'https://openeo-dev.vito.be/openeo/1.0/' with BearerAuth>
cloudmask = c.load_collection("SENTINEL2_L2A_SENTINELHUB", temporal_extent=["2020-01-01","2022-01-01"], bands=["CLP"])
from openeo.processes import ProcessBuilder, lt, if_
def mask(value:ProcessBuilder):
band = value.array_element(0)
clp = value.array_element(1)
return if_(lt(clp,5),band)
lakes= {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-25.780792236328125,
37.87722463210631
],
[
-25.78817367553711,
37.871127007262515
],
[
-25.789203643798825,
37.8627250085565
],
[
-25.779247283935547,
37.86211514878027
],
[
-25.77418327331543,
37.87404037987416
],
[
-25.780792236328125,
37.87722463210631
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-25.788345336914062,
37.85316995894978
],
[
-25.79237937927246,
37.84374922963775
],
[
-25.788087844848633,
37.84280031248598
],
[
-25.786714553833008,
37.85140789965625
],
[
-25.788345336914062,
37.85316995894978
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-25.774526596069336,
37.850933491881875
],
[
-25.775041580200195,
37.84652813106081
],
[
-25.7724666595459,
37.84686701431442
],
[
-25.772809982299805,
37.85012021430965
],
[
-25.774526596069336,
37.850933491881875
]
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#555555",
"stroke-width": 2,
"stroke-opacity": 1,
"fill": "#555555",
"fill-opacity": 0.5,
"name": "Lake Furnas"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-25.33112525939941,
37.7627084265813
],
[
-25.33970832824707,
37.75958708713444
],
[
-25.33421516418457,
37.75130811419222
],
[
-25.327606201171875,
37.75510841351983
],
[
-25.33112525939941,
37.7627084265813
]
]
]
}
},
{
"type": "Feature",
"properties": {
"stroke": "#555555",
"stroke-width": 2,
"stroke-opacity": 1,
"fill": "#555555",
"fill-opacity": 0.5,
"name": "lagoa do caiado"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-28.250763416290283,
38.45765510519811
],
[
-28.252415657043457,
38.45646209534339
],
[
-28.250827789306637,
38.45557152583097
],
[
-28.24956178665161,
38.45694938344215
],
[
-28.250763416290283,
38.45765510519811
]
]
]
}
}
]
}
The Furnas Lake, the second largest lake on the archipelago, holds over one million cubic liters of water. Currently, its ecological status has been downgraded to “bad,” due to the growth of algae, a process which increases the drop in oxygen in the lake water. As a result, the water becomes blurred and loses volume.
The main goal of the Furnas Monitoring and Research Center project is to clean the water basin, to restore the original habitat of the lake and to recover and preserve the ecosystem of the whole area, considered one of the major tourism attractions on the island.
http://siaram.azores.gov.pt/centros-interpretacao/mi-furnas/_intro.html
furnasLake = {
"type": "Polygon",
"coordinates": [
[
[
-25.326704978942878,
37.75884066036112
],
[
-25.329709053039554,
37.76128348360843
],
[
-25.329666137695312,
37.763251254778815
],
[
-25.328550338745117,
37.76474401178003
],
[
-25.328550338745117,
37.767152715226324
],
[
-25.329837799072266,
37.76732233927271
],
[
-25.33309936523437,
37.763183401471984
],
[
-25.335845947265625,
37.76284413400416
],
[
-25.33751964569092,
37.76182632226351
],
[
-25.34035205841065,
37.75982458498279
],
[
-25.338850021362305,
37.756804912698485
],
[
-25.339407920837402,
37.75442980295571
],
[
-25.3373908996582,
37.753615462062704
],
[
-25.334858894348145,
37.75154563861869
],
[
-25.328164100646973,
37.75249572869997
],
[
-25.32679080963135,
37.754972691904946
],
[
-25.326704978942878,
37.75884066036112
]
]
]
}
chl = c.load_collection("TERRASCOPE_S2_CHL_V1", temporal_extent=["2020-01-01","2022-01-01"])
chl = chl.merge_cubes(cloudmask.resample_cube_spatial(chl))
chl = chl.reduce_dimension(dimension="bands",reducer = mask )
median_chl = chl.aggregate_spatial(reducer="median",geometries=furnasLake).execute()
from openeo.rest.conversions import *
import pandas as pd
df = timeseries_json_to_pandas(median_chl)
df.index = pd.to_datetime(df.index)
chlorophyl = df.T
#apply scaling
chlorophyl = chlorophyl / 10
chlorophyl.T.dropna(how='all')
date 2020-11-08 00:00:00+00:00 8.712500 2020-11-18 00:00:00+00:00 44.271154 2020-11-21 00:00:00+00:00 45.450000 2020-11-26 00:00:00+00:00 3.150000 2020-12-11 00:00:00+00:00 2.350000 2020-12-13 00:00:00+00:00 7.347283 2020-12-23 00:00:00+00:00 1.837500 2020-12-26 00:00:00+00:00 19.000000 2020-12-31 00:00:00+00:00 40.000000 2021-01-07 00:00:00+00:00 5.489020 2021-02-04 00:00:00+00:00 3.125000 2021-02-06 00:00:00+00:00 51.700000 2021-02-16 00:00:00+00:00 25.125000 2021-02-24 00:00:00+00:00 9.825000 2021-03-01 00:00:00+00:00 14.950000 2021-03-08 00:00:00+00:00 42.840865 2021-03-18 00:00:00+00:00 29.361111 2021-03-28 00:00:00+00:00 15.736364 2021-04-05 00:00:00+00:00 26.175000 2021-04-25 00:00:00+00:00 0.100000 2021-05-07 00:00:00+00:00 0.558333 2021-05-10 00:00:00+00:00 3.580000 2021-05-12 00:00:00+00:00 6.156731 2021-05-22 00:00:00+00:00 3.506250 2021-05-30 00:00:00+00:00 0.500000 2021-06-01 00:00:00+00:00 2.277083 2021-06-11 00:00:00+00:00 7.163462 2021-06-14 00:00:00+00:00 3.488889 2021-06-19 00:00:00+00:00 1.537500 dtype: float64
chlorophyl.T.interpolate().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f57ba089cf8>
chl = c.load_collection("TERRASCOPE_S2_CHL_V1", temporal_extent=["2020-01-01","2022-01-01"])
chl.mask_polygon(furnasLake).download("lake_furnas_clouds.nc",format="netCDF",options={"stitch":True})
import xarray as xr
import hvplot.xarray
furnas_data = xr.open_dataset("lake_furnas_clouds.nc", engine="h5netcdf")
furnas_data
<xarray.Dataset> Dimensions: (t: 46, x: 118, y: 178) Coordinates: spatial_ref int64 ... * t (t) datetime64[ns] 2020-11-06 2020-11-08 ... 2021-06-26 * x (x) float64 6.462e+05 6.462e+05 ... 6.474e+05 6.474e+05 * y (y) float64 4.18e+06 4.18e+06 4.18e+06 ... 4.181e+06 4.181e+06 Data variables: CHL (t, y, x) uint16 ... Attributes: crs: +proj=utm +zone=26 +datum=WGS84 +units=m +no_defs grid_mapping: spatial_ref nodata: 65535
chl_data = furnas_data['CHL']/10.0
chl_data = chl_data.where(chl_data < 5000, drop=True)
chl_data_filtered = chl_data.where(chl_data.count(['x','y']) > 2000, drop=True)
chl_data_filtered.median(['x','y']).hvplot(dynamic=False)
plot = chl_data_filtered.hvplot(x='x',y='y', by='t', width=200,subplots=True,cmap='GnBu_r',xaxis=False, yaxis=False, colorbar=False,dynamic=False)
plot.redim.range(CHL=(0, 60))