From 2cb9353424d7ee18ebaa6a1c1ae0e2aed7390ba7 Mon Sep 17 00:00:00 2001 From: ValentinaHutter <85164505+ValentinaHutter@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:59:28 +0200 Subject: [PATCH] update notebooks (#11) --- openeo/openeo-sen2like-ndvi.ipynb | 16 +++-- openeo/openeo-sen2like.ipynb | 105 +++++++----------------------- 2 files changed, 33 insertions(+), 88 deletions(-) diff --git a/openeo/openeo-sen2like-ndvi.ipynb b/openeo/openeo-sen2like-ndvi.ipynb index a449d29..0a642dd 100644 --- a/openeo/openeo-sen2like-ndvi.ipynb +++ b/openeo/openeo-sen2like-ndvi.ipynb @@ -29,7 +29,8 @@ "metadata": {}, "outputs": [], "source": [ - "import openeo" + "import openeo\n", + "from openeo.rest.datacube import PGNode, THIS" ] }, { @@ -64,9 +65,11 @@ "source": [ "### Details in openEO's sen2like processing \n", "\n", - "To create an openeo process graph, we define the spatial and temporal extent, we want to process. For sen2like, we additionally set the parameters: \n", + "To create an openeo process graph, we define the spatial and temporal extent, we want to process. The bands which can be processed by sen2like are:\n", + "- 'B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11','B12'\n", + "\n", + "For sen2like, we additionally set the parameters: \n", "- target_product, which can be L2F or L2H\n", - "- the bands, out of: 'B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11','B12'\n", "- the cloud_cover, which is between 1 and 100. The lower the value, the lower the cloud cover for the files must be - files with higher cloud cover are ignored.\n", "- export_original_files: can be True or False - if True, the .SAFE folders are an output of the openEO process as well." ] @@ -80,13 +83,12 @@ "collection = 'SENTINEL2_L1C'\n", "spatial_extent = {\"west\": 15.6, \"east\": 15.7, \"south\": 46.5, \"north\": 46.6}\n", "temporal_extent = [\"2023-09-01\", \"2023-09-30\"]\n", + "bands = [\"B04\", \"B08\"]\n", "\n", - "S2 = conn.load_collection(collection,spatial_extent=spatial_extent,temporal_extent=temporal_extent)\n", + "S2 = conn.load_collection(collection, spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=bands)\n", "sen2like = S2.process('sen2like', {\n", - " 'spatial_extent': spatial_extent, \n", - " 'temporal_extent': temporal_extent, \n", + " 'data': THIS,\n", " 'target_product': 'L2F', \n", - " 'bands': [\"B04\", \"B08\"],\n", " 'export_original_files': False,\n", " 'cloud_cover': 50}) " ] diff --git a/openeo/openeo-sen2like.ipynb b/openeo/openeo-sen2like.ipynb index 78fb11f..4ec4cef 100644 --- a/openeo/openeo-sen2like.ipynb +++ b/openeo/openeo-sen2like.ipynb @@ -29,7 +29,8 @@ "metadata": {}, "outputs": [], "source": [ - "import openeo" + "import openeo\n", + "from openeo.rest.datacube import PGNode, THIS" ] }, { @@ -82,7 +83,7 @@ " }\n", " \n", " \n", - " \n", + " \n", " \n", " " ], @@ -93,83 +94,24 @@ " 'categories': ['cubes'],\n", " 'parameters': [{'name': 'data',\n", " 'description': 'The datacube for which to generate L2F & L2H level data.',\n", - " 'optional': True,\n", - " 'schema': {'type': 'object', 'subtype': 'raster-cube'}},\n", - " {'name': 'spatial_extent',\n", - " 'description': 'Limits the data to load from the collection to the specified bounding box or polygons.\\n\\nThe process puts a pixel into the data cube if the point at the pixel center intersects with the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC).\\n\\nThe GeoJSON can be one of the following feature types:\\n\\n* A `Polygon` or `MultiPolygon` geometry,\\n* a `Feature` with a `Polygon` or `MultiPolygon` geometry,\\n* a `FeatureCollection` containing at least one `Feature` with `Polygon` or `MultiPolygon` geometries, or\\n* a `GeometryCollection` containing `Polygon` or `MultiPolygon` geometries. To maximize interoperability, `GeometryCollection` should be avoided in favour of one of the alternatives above.\\n\\nSet this parameter to `null` to set no limit for the spatial extent. Be careful with this when loading large datasets! It is recommended to use this parameter instead of using ``filter_bbox()`` or ``filter_spatial()`` directly after loading unbounded data.',\n", - " 'optional': True,\n", - " 'schema': [{'type': 'object',\n", - " 'subtype': 'bounding-box',\n", - " 'properties': {'west': {'description': 'West (lower left corner, coordinate axis 1).',\n", - " 'type': 'number'},\n", - " 'south': {'description': 'South (lower left corner, coordinate axis 2).',\n", - " 'type': 'number'},\n", - " 'east': {'description': 'East (upper right corner, coordinate axis 1).',\n", - " 'type': 'number'},\n", - " 'north': {'description': 'North (upper right corner, coordinate axis 2).',\n", - " 'type': 'number'},\n", - " 'base': {'description': 'Base (optional, lower left corner, coordinate axis 3).',\n", - " 'type': ['number', 'null']},\n", - " 'height': {'description': 'Height (optional, upper right corner, coordinate axis 3).',\n", - " 'type': ['number', 'null']},\n", - " 'crs': {'description': 'Coordinate reference system of the extent, specified as as [EPSG code](http://www.epsg-registry.org/), [WKT2 (ISO 19162) string](http://docs.opengeospatial.org/is/18-010r7/18-010r7.html) or [PROJ definition (deprecated)](https://proj.org/usage/quickstart.html). Defaults to `4326` (EPSG code 4326) unless the client explicitly requests a different coordinate reference system.',\n", - " 'anyOf': [{'title': 'EPSG Code',\n", - " 'type': 'integer',\n", - " 'subtype': 'epsg-code',\n", - " 'minimum': 1000,\n", - " 'examples': [3857]},\n", - " {'title': 'WKT2', 'type': 'string', 'subtype': 'wkt2-definition'},\n", - " {'title': 'PROJ definition',\n", - " 'type': 'string',\n", - " 'subtype': 'proj-definition',\n", - " 'deprecated': True}],\n", - " 'default': 4326}},\n", - " 'required': ['west', 'south', 'east', 'north'],\n", - " 'title': 'Bounding Box'}]},\n", - " {'name': 'temporal_extent',\n", - " 'description': 'Limits the data to load from the collection to the specified left-closed temporal interval. Applies to all temporal dimensions. The interval has to be specified as an array with exactly two elements:\\n\\n1. The first element is the start of the temporal interval. The specified instance in time is **included** in the interval.\\n2. The second element is the end of the temporal interval. The specified instance in time is **excluded** from the interval.\\n\\nThe specified temporal strings follow [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.html). Also supports open intervals by setting one of the boundaries to `null`, but never both.\\n\\nSet this parameter to `null` to set no limit for the temporal extent. Be careful with this when loading large datasets! It is recommended to use this parameter instead of using ``filter_temporal()`` directly after loading unbounded data.',\n", - " 'optional': True,\n", - " 'schema': [{'type': 'array',\n", - " 'subtype': 'temporal-interval',\n", - " 'minItems': 2.0,\n", - " 'maxItems': 2.0,\n", - " 'items': {'anyOf': [{'type': 'string',\n", - " 'format': 'date-time',\n", - " 'subtype': 'date-time'},\n", - " {'type': 'string', 'format': 'date', 'subtype': 'date'},\n", - " {'type': 'string',\n", - " 'subtype': 'year',\n", - " 'minLength': 4,\n", - " 'maxLength': 4,\n", - " 'pattern': '^\\\\d{4}$'},\n", - " {'type': 'null'}]},\n", - " 'examples': [['2015-01-01T00:00:00Z', '2016-01-01T00:00:00Z'],\n", - " ['2015-01-01', '2016-01-01']]}]},\n", + " 'optional': False,\n", + " 'schema': {'type': 'object', 'subtype': 'datacube'}},\n", " {'name': 'target_product',\n", " 'description': \"Per default the target_product is set to 'L2F' to generate the fused sen2like product. Set to 'L2H' to generate the harmonised product.\",\n", " 'optional': True,\n", " 'default': 'L2F',\n", " 'schema': {'type': 'string'}},\n", - " {'name': 'bands',\n", - " 'description': \"Only adds the specified bands into the data cube so that bands that don't match the list of band names are not available. Applies to all dimensions of type `bands`.\\n\\nEither the unique band name (metadata field `name` in bands) or one of the common band names (metadata field `common_name` in bands) can be specified. If the unique band name and the common name conflict, the unique band name has a higher priority.\\n\\nThe order of the specified array defines the order of the bands in the data cube. If multiple bands match a common name, all matched bands are included in the original order.\\n\\nIt is recommended to use this parameter instead of using ``filter_bands()`` directly after loading unbounded data.\",\n", - " 'optional': True,\n", - " 'schema': [{'type': 'array',\n", - " 'minItems': 1.0,\n", - " 'items': {'type': 'string', 'subtype': 'band-name'}},\n", - " {'type': 'null',\n", - " 'description': \"Don't filter bands. All bands are included in the data cube.\",\n", - " 'title': 'No filter'}]},\n", - " {'name': 'export_original_files',\n", - " 'description': 'Sen2like produces outputs following the Sentinel 2 .SAFE convention. To enable the download for these, set this to True. ',\n", - " 'optional': True,\n", - " 'default': False,\n", - " 'schema': {'type': 'boolean'}},\n", " {'name': 'cloud_cover',\n", " 'description': 'The Cloud coverage parameter (percentage) to filter MGRS image tile contaminates with strong cloud coverage. ',\n", " 'optional': True,\n", " 'default': 50,\n", - " 'schema': {'type': ['number', 'null']}}],\n", - " 'returns': {'description': \"Sen2like enriched data cube for further processing. The dimensions and dimension properties (name, type, labels, reference system and resolution) correspond to the collection's metadata, but the dimension labels are restricted as specified in the parameters.\",\n", + " 'schema': {'type': ['number', 'null']}},\n", + " {'name': 'export_original_files',\n", + " 'description': 'Sen2like produces outputs following the Sentinel 2 .SAFE convention. To enable the download for these, set this to True. The results will then include .zip files with the .SAFE folders inside. ',\n", + " 'optional': True,\n", + " 'default': False,\n", + " 'schema': {'type': 'boolean'}}],\n", + " 'returns': {'description': 'Sen2like enriched data cube for further processing. For further openEO processing on the sen2like datacube, the datacube is loaded in the Equi7 coordinate reference system, with the spatio-temporal extent of the initially requested data. The resolution is based on the highest resolution of the requested bands, where bands with lower resolution are resampled to the higher resolution respectively. ',\n", " 'schema': {'type': 'object', 'subtype': 'datacube'}},\n", " 'experimental': True,\n", " 'links': [{'rel': 'about',\n", @@ -195,9 +137,11 @@ "source": [ "### Details in openEO's sen2like processing \n", "\n", - "To create an openeo process graph, we define the spatial and temporal extent, we want to process. For sen2like, we additionally set the parameters: \n", + "To create an openeo process graph, we define the spatial and temporal extent, we want to process. The bands which can be processed by sen2like are:\n", + "- 'B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11','B12'\n", + "\n", + "For sen2like, we additionally set the parameters: \n", "- target_product, which can be L2F or L2H\n", - "- the bands, out of: 'B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11','B12'\n", "- the cloud_cover, which is between 1 and 100. The lower the value, the lower the cloud cover for the files must be - files with higher cloud cover are ignored.\n", "- export_original_files: can be True or False - if True, the .SAFE folders are an output of the openEO process as well." ] @@ -211,13 +155,12 @@ "collection = 'SENTINEL2_L1C'\n", "spatial_extent = {\"west\": 15.6, \"east\": 15.7, \"south\": 46.5, \"north\": 46.6}\n", "temporal_extent = [\"2023-07-01\", \"2023-09-30\"]\n", + "bands = [\"B02\", \"B03\", \"B04\"]\n", "\n", - "S2 = conn.load_collection(collection,spatial_extent=spatial_extent,temporal_extent=temporal_extent)\n", + "S2 = conn.load_collection(collection, spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=bands)\n", "sen2like = S2.process('sen2like', {\n", - " 'spatial_extent': spatial_extent, \n", - " 'temporal_extent': temporal_extent, \n", + " 'data': THIS,\n", " 'target_product': 'L2F', \n", - " 'bands': [\"B02\", \"B03\", \"B04\"],\n", " 'export_original_files': True,\n", " 'cloud_cover': 50}) " ] @@ -249,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -258,7 +201,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -280,15 +223,15 @@ " }\n", " \n", " \n", - " \n", + " \n", " \n", " " ], "text/plain": [ - "" + "" ] }, - "execution_count": 8, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" }