From 16cff017f5d2f3f3fff16fb1ca1cf9ed61846bcd Mon Sep 17 00:00:00 2001 From: cbur24 Date: Tue, 30 Nov 2021 00:27:37 +0000 Subject: [PATCH 1/3] change nodata for prob layer to 255, update prob style --- products/crop_mask_eastern.odc-product.yaml | 2 +- products/crop_mask_northern.odc-product.yaml | 2 +- products/crop_mask_sahel.odc-product.yaml | 2 +- products/crop_mask_western.odc-product.yaml | 2 +- .../agriculture/ows_crop_mask_cfg.py | 248 ------------------ .../ows_refactored/dev_af_ows_root_cfg.py | 2 +- 6 files changed, 5 insertions(+), 253 deletions(-) diff --git a/products/crop_mask_eastern.odc-product.yaml b/products/crop_mask_eastern.odc-product.yaml index d648018b..b3accfb3 100644 --- a/products/crop_mask_eastern.odc-product.yaml +++ b/products/crop_mask_eastern.odc-product.yaml @@ -26,7 +26,7 @@ measurements: - name: prob aliases: ['crop_prob', 'PROB'] dtype: uint8 - nodata: 0 + nodata: 255 units: '1' - name: filtered diff --git a/products/crop_mask_northern.odc-product.yaml b/products/crop_mask_northern.odc-product.yaml index 6b0ce721..98196030 100644 --- a/products/crop_mask_northern.odc-product.yaml +++ b/products/crop_mask_northern.odc-product.yaml @@ -26,7 +26,7 @@ measurements: - name: prob aliases: ['crop_prob', 'PROB'] dtype: uint8 - nodata: 0 + nodata: 255 units: '1' - name: filtered diff --git a/products/crop_mask_sahel.odc-product.yaml b/products/crop_mask_sahel.odc-product.yaml index 373f5e67..f6534b91 100644 --- a/products/crop_mask_sahel.odc-product.yaml +++ b/products/crop_mask_sahel.odc-product.yaml @@ -26,7 +26,7 @@ measurements: - name: prob aliases: ['crop_prob', 'PROB'] dtype: uint8 - nodata: 0 + nodata: 255 units: '1' - name: filtered diff --git a/products/crop_mask_western.odc-product.yaml b/products/crop_mask_western.odc-product.yaml index 3511bf31..624c500d 100644 --- a/products/crop_mask_western.odc-product.yaml +++ b/products/crop_mask_western.odc-product.yaml @@ -26,7 +26,7 @@ measurements: - name: prob aliases: ['crop_prob', 'PROB'] dtype: uint8 - nodata: 0 + nodata: 255 units: '1' - name: filtered diff --git a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py index b89938bb..70a76ea5 100644 --- a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py +++ b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py @@ -18,7 +18,6 @@ { "value": 0, "color": "black", - "alpha": 0.0, }, { "value": 1, @@ -328,250 +327,3 @@ ], } -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# ----------------------------testing layers-------------- -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -style_crop_mask_prob_2 = { - "name": "prob", - "title": "Probability of cropping", - "abstract": "Probability of cropping", - "needed_bands": ["prob"], - "index_function": { - "function": "datacube_ows.band_utils.single_band", - "mapped_bands": True, - "kwargs": { - "band": "prob", - }, - }, - "color_ramp": [ - { - "value": 0, - "color": "black", - }, - { - "value": 1, - "color": "#010007", - }, - { - "value": 10, - "color": "#170b3b", - }, - { - "value": 20, - "color": "#410967", - }, - { - "value": 30, - "color": "#6b176e", - }, - { - "value": 40, - "color": "#952666", - }, - { - "value": 50, - "color": "#bb3754", - }, - { - "value": 60, - "color": "#dd5238", - }, - { - "value": 70, - "color": "#f37719", - }, - { - "value": 80, - "color": "#fba60b", - }, - { - "value": 90, - "color": "#f5d948", - }, - { - "value": 100, - "color": "#fcfea4", - }, - ], - "range": [0, 100], - "legend": { - "begin": "0", - "end": "100", - "ticks_every": "20", - }, -} - -dev_layers = { - "title": "Cropland extent map (provisional)", - "abstract": """The Digital Earth Africa cropland extent service identifies areas of cropping in Africa, using Copernicus Sentinel-2 satellite imagery and machine learning techniques. The map indicates either the presence or absence of crop. An accurate, high-resolution, and regularly-updated cropland area map for the African continent is recognised as a useful tool in crop monitoring services. A precise and accurate cropland extent map indicating where cropland occurs serves as a basis for higher-level products, such as crop type and watering intensity. - -The cropland extent map for Africa is currently avilable for Eastern, Western, Northern, and Sahelian Africa and is therefore a provisional product. -""", - "layers": [ - { - "title": "Cropland extent 2019 - Eastern Africa", - "name": "crop_mask_eastern", - "abstract": """ -Digital Earth Africa's cropland extent map for Eastern Africa (2019) shows the estimated location of croplands in the countries of Tanzania, Kenya, Uganda, Ethiopia, Rwanda, and Burundi for the period January to December 2019. Cropland is defined as: "a piece of land of minimum 0.01 ha (a single 10m x 10m pixel) that is sowed/planted and harvest-able at least once within the 12 months after the sowing/planting date." This definition will exclude non-planted grazing lands and perennial crops which can be difficult for satellite imagery to differentiate from natural vegetation. - -This provisional cropland extent map has a resolution of 10m, and was built using Copernicus Sentinel-2 satellite images from 2019. The cropland extent map was produced using extensive training data from Eastern Africa, coupled with a Random Forest machine learning model. For a detailed exploration of the methods used to produce the cropland extent map, read the Jupyter Notebooks in DE Africa’s crop-mask GitHub repository. - -An independent validation dataset suggests this service has an overall accuracy of 90.3 %. The algorithm tends to report more omission errors (labelling actual crops as non-crops) than commission errors (labelling non-crops as crops). Where commission errors occur they tend to be focussed around wetlands and seasonal grasslands (e.g. in the Serengeti) which spectrally resemble some kinds of cropping. - -The crop mask contains three measurements: -- mask ("Cropped land"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is a pixel-based cropland extent map, meaning the map displays the raw output of the pixel-based Random Forest classification. -- prob ("Probability of cropping"): This band displays the prediction probabilities for the 'crop' class during 2019. As this service used a random forest classifier, the prediction probabilities refer to the percentage of trees that voted for the random forest classification. For example, if the model had 200 decision trees in the random forest, and 150 of the trees voted 'crop', the prediction probability is 150 / 200 x 100 = 75 %. Thresholding this band at 50 % will produce a map identical to mask. -- filtered ("Cropped land (object-filtered)"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is an object-based cropland extent map where the mask band has filtered using an image segmentation algorithm. During this process, segments smaller than 1 Ha (100 10m x 10m pixels) are merged with neighbouring segments, resulting in a map where the smallest classified region is 1 Ha in size. The filtered dataset is provided as small commission errors are removed by this process, and the 'salt and pepper' effect typical of classifying pixels is diminished. - -More technical information about the cropland extent service can be found in the User Guide (https://docs.digitalearthafrica.org/en/latest/data_specs/Cropland_extent_specs.html) - -Cropland extent maps are a foundational, baseline layer in high-order crop health and crop productivity products which necessarily rely on knowing where cropping occurs before further analysis can take place. - -This service is accessible through OGC Web Service (https://ows.digitalearth.africa/), for analysis in DE Africa Sandbox JupyterLab (https://github.com/digitalearthafrica/deafrica-sandbox-notebooks/wiki) and for direct download click on a tile in the explorer page (https://explorer.dev.digitalearth.africa/products/crop_mask_eastern/extents -""", - "product_name": "crop_mask_eastern", - "time_resolution": "year", - "bands": bands_crop_mask, - "resource_limits": reslim_alos_palsar, - "image_processing": { - "extent_mask_func": "datacube_ows.ogc_utils.mask_by_val", - "always_fetch_bands": [], - "manual_merge": False, - }, - "native_crs": "EPSG:6933", - "native_resolution": [10, -10], - "styling": { - "default_style": "green", - "styles": [ - style_crop_mask_green, - style_crop_mask_filtered_yellow, - style_crop_mask_prob_2, - ], - }, - }, - { - "title": "Cropland extent 2019 - Western Africa", - "name": "crop_mask_western", - "abstract": """ -Digital Earth Africa's cropland extent map for Western Africa (2019) shows the estimated location of croplands in the countries of Nigeria, Benin, Togo, Ghana, Cote d’Ivoire, Liberia, Sierra Leone, Guinea, and Guinea-Bissau for the period January to December 2019. Cropland is defined as: "a piece of land of minimum 0.01 ha (a single 10m x 10m pixel) that is sowed/planted and harvest-able at least once within the 12 months after the sowing/planting date." This definition will exclude non-planted grazing lands and perennial crops which can be difficult for satellite imagery to differentiate from natural vegetation. - -This provisional cropland extent map has a resolution of 10m, and was built using Copernicus Sentinel-2 satellite images from 2019. The cropland extent map was produced using extensive training data from Western Africa, coupled with a Random Forest machine learning model. For a detailed exploration of the methods used to produce the cropland extent map, read the Jupyter Notebooks in DE Africa’s crop-mask GitHub repository. - -An independent validation dataset suggests this service has an overall accuracy of 83.6 %. The algorithm tends to report more omission errors (labelling actual crops as non-crops) than commission errors (labelling non-crops as crops). Where commission errors occur they tend to be focussed around wetlands and seasonal grasslands which spectrally resemble some kinds of cropping. - -The crop mask contains three measurements: -- mask ("Cropped land"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is a pixel-based cropland extent map, meaning the map displays the raw output of the pixel-based Random Forest classification. -- prob ("Probability of cropping"): This band displays the prediction probabilities for the 'crop' class during 2019. As this service used a random forest classifier, the prediction probabilities refer to the percentage of trees that voted for the random forest classification. For example, if the model had 200 decision trees in the random forest, and 150 of the trees voted 'crop', the prediction probability is 150 / 200 x 100 = 75 %. Thresholding this band at 50 % will produce a map identical to mask. -- filtered ("Cropped land (object-filtered)"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is an object-based cropland extent map where the mask band has filtered using an image segmentation algorithm. During this process, segments smaller than 1 Ha (100 10m x 10m pixels) are merged with neighbouring segments, resulting in a map where the smallest classified region is 1 Ha in size. The filtered dataset is provided as small commission errors are removed by this process, and the 'salt and pepper' effect typical of classifying pixels is diminished. - -More technical information about the cropland extent service can be found in the User Guide (https://docs.digitalearthafrica.org/en/latest/data_specs/Cropland_extent_specs.html) - -Cropland extent maps are a foundational, baseline layer in high-order crop health and crop productivity products which necessarily rely on knowing where cropping occurs before further analysis can take place. - -This service is accessible through OGC Web Service (https://ows.digitalearth.africa/), for analysis in DE Africa Sandbox JupyterLab (https://github.com/digitalearthafrica/deafrica-sandbox-notebooks/wiki) and for direct download click on a tile in the explorer page (https://explorer.dev.digitalearth.africa/products/crop_mask_western/extents) -""", - "product_name": "crop_mask_western", - "time_resolution": "year", - "bands": bands_crop_mask, - "resource_limits": reslim_alos_palsar, - "image_processing": { - "extent_mask_func": "datacube_ows.ogc_utils.mask_by_val", - "always_fetch_bands": [], - "manual_merge": False, - }, - "native_crs": "EPSG:6933", - "native_resolution": [10, -10], - "styling": { - "default_style": "green", - "styles": [ - style_crop_mask_green, - style_crop_mask_filtered_yellow, - style_crop_mask_prob_2, - ], - }, - }, - { - "title": "Cropland extent 2019 - Sahel Africa", - "name": "crop_mask_sahel", - "abstract": """ -Digital Earth Africa's cropland extent map for Sahel Africa (2019) shows the estimated location of croplands in the countries of Mauritania, Senegal, Gambia, Mali, Burkina Faso, Niger, Chad, Sudan, South Sudan, Somalia, Djibouti, and Eritrea for the period January to December 2019. Cropland is defined as: "a piece of land of minimum 0.01 ha (a single 10m x 10m pixel) that is sowed/planted and harvest-able at least once within the 12 months after the sowing/planting date." This definition will exclude non-planted grazing lands and perennial crops which can be difficult for satellite imagery to differentiate from natural vegetation. - -This provisional cropland extent map has a resolution of 10m, and was built using Copernicus Sentinel-2 satellite images from 2019. The cropland extent map was produced using extensive training data from across Sahel Africa, coupled with a Random Forest machine learning model. For a detailed exploration of the methods used to produce the cropland extent map, read the Jupyter Notebooks in DE Africa’s crop-mask GitHub repository. - -An independent validation dataset suggests this service has an overall accuracy of 87 %. The algorithm tends to report more omission errors (labelling actual crops as non-crops) than commission errors (labelling non-crops as crops). Where commission errors occur they tend to be focussed around wetlands and seasonal grasslands which spectrally resemble some kinds of cropping. - -The crop mask contains three measurements: -- mask ("Cropped land"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is a pixel-based cropland extent map, meaning the map displays the raw output of the pixel-based Random Forest classification. -- prob ("Probability of cropping"): This band displays the prediction probabilities for the 'crop' class during 2019. As this service used a random forest classifier, the prediction probabilities refer to the percentage of trees that voted for the random forest classification. For example, if the model had 200 decision trees in the random forest, and 150 of the trees voted 'crop', the prediction probability is 150 / 200 x 100 = 75 %. Thresholding this band at 50 % will produce a map identical to mask. -- filtered ("Cropped land (object-filtered)"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is an object-based cropland extent map where the mask band has filtered using an image segmentation algorithm. During this process, segments smaller than 1 Ha (100 10m x 10m pixels) are merged with neighbouring segments, resulting in a map where the smallest classified region is 1 Ha in size. The filtered dataset is provided as small commission errors are removed by this process, and the 'salt and pepper' effect typical of classifying pixels is diminished. - -More technical information about the cropland extent service can be found in the User Guide (https://docs.digitalearthafrica.org/en/latest/data_specs/Cropland_extent_specs.html) - -Cropland extent maps are a foundational, baseline layer in high-order crop health and crop productivity products which necessarily rely on knowing where cropping occurs before further analysis can take place. - -This service is accessible through OGC Web Service (https://ows.digitalearth.africa/), for analysis in DE Africa Sandbox JupyterLab (https://github.com/digitalearthafrica/deafrica-sandbox-notebooks/wiki) and for direct download click on a tile in the explorer page (https://explorer.dev.digitalearth.africa/products/crop_mask_sahel/extents) -""", - "product_name": "crop_mask_sahel", - "time_resolution": "year", - "bands": bands_crop_mask, - "resource_limits": reslim_alos_palsar, - "image_processing": { - "extent_mask_func": "datacube_ows.ogc_utils.mask_by_val", - "always_fetch_bands": [], - "manual_merge": False, - }, - "native_crs": "EPSG:6933", - "native_resolution": [10, -10], - "styling": { - "default_style": "green", - "styles": [ - style_crop_mask_green, - style_crop_mask_filtered_yellow, - style_crop_mask_prob_2, - ], - }, - }, - { - "title": "Cropland extent 2019 - Northern Africa", - "name": "crop_mask_northern", - "abstract": """ -Digital Earth Africa's cropland extent map for Northern Africa (2019) shows the estimated location of croplands in the countries of Morocco, Algeria, Tunisia, Libya, and Egypt for the period January to December 2019. Cropland is defined as: "a piece of land of minimum 0.01 ha (a single 10m x 10m pixel) that is sowed/planted and harvest-able at least once within the 12 months after the sowing/planting date." This definition will exclude non-planted grazing lands and perennial crops which can be difficult for satellite imagery to differentiate from natural vegetation. - -This provisional cropland extent map has a resolution of 10m, and was built using Copernicus Sentinel-2 satellite images from 2019. The cropland extent map was produced using extensive training data from Northern Africa, coupled with a Random Forest machine learning model. For a detailed exploration of the methods used to produce the cropland extent map, read the Jupyter Notebooks in DE Africa’s crop-mask GitHub repository. - -An independent validation dataset suggests this service has an overall accuracy of 94 %. The algorithm tends to report more omission errors (labelling actual crops as non-crops) than commission errors (labelling non-crops as crops). Where commission errors occur they tend to be focussed around wetlands and seasonal grasslands which spectrally resemble some kinds of cropping. - -The crop mask contains three measurements: -- mask ("Cropped land"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is a pixel-based cropland extent map, meaning the map displays the raw output of the pixel-based Random Forest classification. -- prob ("Probability of cropping"): This band displays the prediction probabilities for the 'crop' class during 2019. As this service used a random forest classifier, the prediction probabilities refer to the percentage of trees that voted for the random forest classification. For example, if the model had 200 decision trees in the random forest, and 150 of the trees voted 'crop', the prediction probability is 150 / 200 x 100 = 75 %. Thresholding this band at 50 % will produce a map identical to mask. -- filtered ("Cropped land (object-filtered)"): This band displays cropped regions as a binary map. Values of 1 indicate the presence of crops, while a value of 0 indicates the absence of cropping. This band is an object-based cropland extent map where the mask band has filtered using an image segmentation algorithm. During this process, segments smaller than 1 Ha (100 10m x 10m pixels) are merged with neighbouring segments, resulting in a map where the smallest classified region is 1 Ha in size. The filtered dataset is provided as small commission errors are removed by this process, and the 'salt and pepper' effect typical of classifying pixels is diminished. - -More technical information about the cropland extent service can be found in the User Guide (https://docs.digitalearthafrica.org/en/latest/data_specs/Cropland_extent_specs.html) - -Cropland extent maps are a foundational, baseline layer in high-order crop health and crop productivity products which necessarily rely on knowing where cropping occurs before further analysis can take place. - -This service is accessible through OGC Web Service (https://ows.digitalearth.africa/), for analysis in DE Africa Sandbox JupyterLab (https://github.com/digitalearthafrica/deafrica-sandbox-notebooks/wiki)and for direct download click on a tile in the explorer page (https://explorer.dev.digitalearth.africa/products/crop_mask_northern/extents -""", - "product_name": "crop_mask_northern", - "time_resolution": "year", - "bands": bands_crop_mask, - "resource_limits": reslim_alos_palsar, - "image_processing": { - "extent_mask_func": "datacube_ows.ogc_utils.mask_by_val", - "always_fetch_bands": [], - "manual_merge": False, - }, - "native_crs": "EPSG:6933", - "native_resolution": [10, -10], - "styling": { - "default_style": "green", - "styles": [ - style_crop_mask_green, - style_crop_mask_filtered_yellow, - style_crop_mask_prob_2, - ], - }, - }, - ], -} diff --git a/services/ows_refactored/dev_af_ows_root_cfg.py b/services/ows_refactored/dev_af_ows_root_cfg.py index f52f14d7..0978ca03 100644 --- a/services/ows_refactored/dev_af_ows_root_cfg.py +++ b/services/ows_refactored/dev_af_ows_root_cfg.py @@ -260,7 +260,7 @@ "abstract": """Agriculture""", "layers": [ { - "include": "ows_refactored.agriculture.ows_crop_mask_cfg.dev_layers", + "include": "ows_refactored.agriculture.ows_crop_mask_cfg.layers", "type": "python", }, ], From db3492d64f5c89f726d207926ee1f35faa500eac Mon Sep 17 00:00:00 2001 From: cbur24 Date: Tue, 30 Nov 2021 00:30:12 +0000 Subject: [PATCH 2/3] rm blank line --- services/ows_refactored/agriculture/ows_crop_mask_cfg.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py index 70a76ea5..cddc815a 100644 --- a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py +++ b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py @@ -325,5 +325,4 @@ }, }, ], -} - +} \ No newline at end of file From 03e784ab212d727f718f8dd52aa57d6435a912e5 Mon Sep 17 00:00:00 2001 From: cbur24 Date: Tue, 30 Nov 2021 00:32:36 +0000 Subject: [PATCH 3/3] more linting bs --- services/ows_refactored/agriculture/ows_crop_mask_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py index cddc815a..59fc73e1 100644 --- a/services/ows_refactored/agriculture/ows_crop_mask_cfg.py +++ b/services/ows_refactored/agriculture/ows_crop_mask_cfg.py @@ -325,4 +325,4 @@ }, }, ], -} \ No newline at end of file +}