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/docs/CHANGELOG.md b/docs/CHANGELOG.md index 68ec529edc..854bd19899 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,3 +9,4 @@ - Fix github actions - Add TARGET landcover production - Force TARGET ROOF fraction to 0.75 when BUILDING fraction is greater than 0.75 +- Force TARGET W indicator to the grid resolution 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 b3ecff825b..17b9a6bcfb 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,