From 018dc88591885ed3f95c7a73a1f3d1201132ca2a Mon Sep 17 00:00:00 2001 From: ebocher Date: Tue, 10 Dec 2024 20:02:03 +0100 Subject: [PATCH 1/2] Force target grid size to at least 100 meters Force STREET_WIDTH to be less than the grid resolution --- .../geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy | 5 ++++- .../geoclimate/geoindicators/GridIndicators.groovy | 7 +++++-- .../groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy | 7 ++++++- .../org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy index 05e9e04424..cec231a44e 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/AbstractBDTopoWorkflow.groovy @@ -602,6 +602,9 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { "IMPERVIOUS_FRACTION", "VEGETATION_FRACTION"]) } + if(x_size != y_size){ + throw new Exception("TARGET model supports only regular grid. Please set the same x and y resolutions") + } def grid_indicators_tmp = [ "x_size" : x_size, "y_size" : y_size, @@ -913,7 +916,7 @@ abstract class AbstractBDTopoWorkflow extends BDTopoUtils { } //We must transform the grid_indicators to produce the target land input if(processing_parameters.rsu_indicators.indicatorUse.contains("TARGET")){ - results.put("grid_target", Geoindicators.GridIndicators.formatGrid4Target(h2gis_datasource, rasterizedIndicators)) + results.put("grid_target", Geoindicators.GridIndicators.formatGrid4Target(h2gis_datasource, rasterizedIndicators, x_size)) } info("End computing grid_indicators") } diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy index 655fae5dcd..18bbdc452f 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy @@ -372,11 +372,12 @@ String gridDistances(JdbcDataSource datasource, String input_polygons, String gr * * @param datasource input database * @param gridTable input grid_indicators + * @param resolution grid resolution in meters * @return a grid formated * * @author Erwan Bocher, CNRS */ -String formatGrid4Target(JdbcDataSource datasource, String gridTable) { +String formatGrid4Target(JdbcDataSource datasource, String gridTable, float resolution) { //Format target landcover def grid_target = postfix("grid_target") try { @@ -400,7 +401,9 @@ String formatGrid4Target(JdbcDataSource datasource, String gridTable) { 0 AS "irr", AVG_HEIGHT_ROOF_AREA_WEIGHTED AS "H", CASE WHEN - STREET_WIDTH IS NULL THEN 0.1 ELSE STREET_WIDTH END AS "W" + STREET_WIDTH IS NULL THEN 0.1 + WHEN STREET_WIDTH > ${resolution} THEN ${resolution} + ELSE STREET_WIDTH END AS "W" FROM ${gridTable} """) return grid_target diff --git a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy index 4253ae5282..0dd447ca6f 100644 --- a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy +++ b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/WorkflowOSM.groovy @@ -637,7 +637,7 @@ Map osm_processing(JdbcDataSource h2gis_datasource, def processing_parameters, d } //We must transform the grid_indicators to produce the target land input if(rsu_indicators_params.indicatorUse.contains("TARGET")){ - results.put("grid_target", Geoindicators.GridIndicators.formatGrid4Target(h2gis_datasource, rasterizedIndicators)) + results.put("grid_target", Geoindicators.GridIndicators.formatGrid4Target(h2gis_datasource, rasterizedIndicators, x_size)) } info("End computing grid_indicators") } @@ -923,6 +923,11 @@ def extractProcessingParameters(def processing_parameters) throws Exception { "IMPERVIOUS_FRACTION", "VEGETATION_FRACTION"]) } + + if(x_size != y_size){ + throw new Exception("TARGET model supports only regular grid. Please set the same x and y resolutions") + } + def grid_indicators_tmp = [ "x_size" : x_size, "y_size" : y_size, diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy index fee294d8f7..fee2a9059d 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/WorflowOSMTest.groovy @@ -724,7 +724,7 @@ class WorflowOSMTest extends WorkflowAbstractTest { def grid_size = 100 location =[47.214976592711274,-1.6425595375815742,47.25814872718718,-1.5659501122281323] //location=[47.215334,-1.558058,47.216646,-1.556185] - //location = nominatim.bbox + location = nominatim.bbox //location=[51.2, 1.0, 51.4, 1.2] /* location =[ 48.84017284026897, 2.3061887733275785, @@ -759,7 +759,7 @@ class WorflowOSMTest extends WorkflowAbstractTest { "parameters" : ["distance" : 0, "rsu_indicators" : [ - "indicatorUse": ["LCZ", "TEB", "TARGET"] //, "UTRF"] + "indicatorUse": ["TARGET"] //, "UTRF"] ], "grid_indicators" : [ "x_size" : grid_size, From 5a67f39a11b1964ec4fb7c148b98a9f3316bdd58 Mon Sep 17 00:00:00 2001 From: ebocher Date: Tue, 10 Dec 2024 20:03:19 +0100 Subject: [PATCH 2/2] Doc --- docs/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a8281aae34..f72f27478e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,3 +8,4 @@ - Add a test to check if the worldpop service is available - Fix github actions - Add TARGET landcover production +- Force TARGET W indicator to the grid resolution