From a1f7d39fc081e1da135fdbb47cf0115b64204c71 Mon Sep 17 00:00:00 2001 From: Julia Haas <83269984+juleshaas@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:19:08 +0100 Subject: [PATCH] unify parameters for buildings addons (#70) * unify parameters for buildings addons * undo changes in import addon * change fields to required * generalize default values * adapt keyword --- .../r.extract.buildings.worker.py | 24 +++------ .../r.extract.buildings.py | 40 +++++++-------- .../r.extract.greenroofs.worker.py | 41 +++++---------- .../r.extract.greenroofs.py | 51 ++++++++----------- .../v.cd.areas.worker/v.cd.areas.worker.py | 10 ++-- .../v.cd.areas/v.cd.areas.py | 9 ++-- 6 files changed, 70 insertions(+), 105 deletions(-) diff --git a/grass-gis-addons/m.analyse.buildings/r.extract.buildings.worker/r.extract.buildings.worker.py b/grass-gis-addons/m.analyse.buildings/r.extract.buildings.worker/r.extract.buildings.worker.py index ec9eb7f..089d2ed 100644 --- a/grass-gis-addons/m.analyse.buildings/r.extract.buildings.worker/r.extract.buildings.worker.py +++ b/grass-gis-addons/m.analyse.buildings/r.extract.buildings.worker/r.extract.buildings.worker.py @@ -40,43 +40,35 @@ # %option G_OPT_R_INPUT # % key: ndsm -# % type: string -# % required: yes -# % label: Name of the nDSM +# % label: Name of the nDSM raster # %end # %option G_OPT_R_INPUT # % key: ndvi_raster -# % type: string -# % required: yes # % label: Name of the NDVI raster # %end # %option G_OPT_V_INPUT # % key: fnk_vector -# % type: string # % required: no -# % label: Vector map containing Flaechennutzungskartierung +# % label: Name of vector map containing the Flaechennutzungskartierung # %end # %option G_OPT_R_INPUT # % key: fnk_raster -# % type: string # % required: no -# % label: Raster map containing Flaechennutzungskartierung +# % label: Name of raster map containing the Flaechennutzungskartierung # %end -# %option G_OPT_R_INPUT +# %option G_OPT_DB_COLUMN # % key: fnk_column -# % type: string -# % required: no -# % label: Integer column containing FNK-code +# % label: Name of integer column containing FNK-code # %end # %option # % key: min_size # % type: integer -# % required: no +# % required: yes # % multiple: no # % label: Minimum size of buildings in sqm # % answer: 20 @@ -85,7 +77,7 @@ # %option # % key: max_fd # % type: double -# % required: no +# % required: yes # % multiple: no # % label: Maximum value of fractal dimension of identified objects (see v.to.db) # % answer: 2.1 @@ -101,8 +93,6 @@ # %option G_OPT_R_OUTPUT # % key: output -# % type: string -# % required: yes # % label: Name for output vector map # %end diff --git a/grass-gis-addons/m.analyse.buildings/r.extract.buildings/r.extract.buildings.py b/grass-gis-addons/m.analyse.buildings/r.extract.buildings/r.extract.buildings.py index f0d9973..cf796ca 100644 --- a/grass-gis-addons/m.analyse.buildings/r.extract.buildings/r.extract.buildings.py +++ b/grass-gis-addons/m.analyse.buildings/r.extract.buildings/r.extract.buildings.py @@ -26,42 +26,37 @@ # %option G_OPT_R_INPUT # % key: ndsm -# % type: string -# % required: yes # % label: Name of the nDSM raster +# % answer: ndsm # % guisection: Input # %end # %option G_OPT_R_INPUT # % key: ndvi_raster -# % type: string -# % required: yes # % label: Name of the NDVI raster +# % answer: dop_ndvi_05 # % guisection: Input # %end # %option G_OPT_V_INPUT # % key: fnk_vector -# % type: string -# % required: yes -# % label: Vector map containing Flaechennutzungskartierung +# % label: Name of vector map containing the Flaechennutzungskartierung +# % answer: fnk # % guisection: Input # % guidependency: fnk_column # %end # %option G_OPT_DB_COLUMN # % key: fnk_column -# % type: string # % required: yes -# % multiple: no -# % label: Integer column containing FNK-code +# % label: Name of integer column containing FNK-code # % guisection: Input # %end # %option # % key: min_size # % type: integer -# % required: no +# % required: yes # % multiple: no # % label: Minimum size of buildings in sqm # % answer: 20 @@ -71,7 +66,7 @@ # %option # % key: max_fd # % type: double -# % required: no +# % required: yes # % multiple: no # % label: Maximum value of fractal dimension of identified objects (see v.to.db) # % answer: 2.1 @@ -79,28 +74,29 @@ # %end # %option -# % key: ndvi_thresh +# % key: ndvi_perc # % type: integer # % required: no # % multiple: no -# % label: Define fix NDVI threshold (on a scale from 0-255) instead of estimating it from FNK +# % label: NDVI percentile in vegetated areas to use for thresholding +# TODO: make radio button and add default +# # % answer: 5 # % guisection: Parameters # %end # %option -# % key: ndvi_perc +# % key: ndvi_thresh # % type: integer # % required: no # % multiple: no -# % label: NDVI percentile in vegetated areas to use for thresholding +# % label: Fix NDVI threshold (on a scale from 0-255) instead of estimated value from ndvi_perc and FNK +# TODO: make radio button and add default +# # % answer: 145 # % guisection: Parameters # %end # %option G_OPT_V_OUTPUT -# % key: output -# % type: string -# % required: yes -# % label: Name for output vector map +# % answer: buildings # % guisection: Output # %end @@ -119,7 +115,7 @@ # % type: integer # % required: yes # % multiple: no -# % label: Define edge length of grid tiles for parallel processing +# % label: Edge length of grid tiles for parallel processing # % answer: 1000 # % guisection: Parallel processing # %end @@ -638,7 +634,7 @@ def main(): quiet=True, ) - grass.message(_(f"Created output vector layer {output_vect}")) + grass.message(_(f"Created output vector layer <{output_vect}>.")) if __name__ == "__main__": diff --git a/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs.worker/r.extract.greenroofs.worker.py b/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs.worker/r.extract.greenroofs.worker.py index 4a1fc85..95475b8 100644 --- a/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs.worker/r.extract.greenroofs.worker.py +++ b/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs.worker/r.extract.greenroofs.worker.py @@ -24,6 +24,11 @@ # % keyword: worker # %end +# %option G_OPT_V_INPUT +# % key: area +# % label: Vector map containing area +# %end + # %option # % key: new_mapset # % type: string @@ -32,59 +37,38 @@ # % label: Name of new mapset where to compute the building MASK # %end -# %option G_OPT_V_INPUT -# % key: area -# % type: string -# % required: yes -# % label: Vector map containing area -# %end - # %option G_OPT_V_INPUT # % key: building_outlines -# % type: string -# % required: yes -# % label: Vector map containing outlines of buildings +# % label: Name of vector map containing outlines of buildings # %end # %option G_OPT_R_INPUT # % key: buildings -# % type: string -# % required: yes -# % label: Raster map containing buildings +# % label: Name of raster map containing buildings # %end # %option G_OPT_R_INPUT # % key: ndsm -# % type: string -# % required: yes # % label: Name of the nDSM raster # %end # %option G_OPT_R_INPUT # % key: gb_ratio -# % type: string -# % required: yes # % label: Name of the GB-ratio raster # %end # %option G_OPT_R_INPUT # % key: rg_ratio -# % type: string -# % required: yes # % label: Name of the RG-ratio raster # %end # %option G_OPT_R_INPUT # % key: brightness -# % type: string -# % required: yes # % label: Name of the brightness raster # %end # %option G_OPT_R_INPUT # % key: ndvi -# % type: string -# % required: yes # % label: Name of the NDVI raster # %end @@ -93,7 +77,7 @@ # % type: integer # % required: yes # % multiple: no -# % label: Define fix Green_blue_ratio threshold (on a scale from 0-255) +# % label: Fix value for green-blue-ratio threshold (on a scale from 0-255) # %end # %option @@ -101,7 +85,7 @@ # % type: integer # % required: no # % multiple: no -# % label: Define fix nDSM median +# % label: Value for nDSM median # %end # %option @@ -109,7 +93,7 @@ # % type: integer # % required: no # % multiple: no -# % label: Define fix nDSM low percentile +# % label: Fix value for nDSM low percentile # %end # %option @@ -117,7 +101,7 @@ # % type: integer # % required: no # % multiple: no -# % label: Define fix nDSM high percentile +# % label: Fix value for nDSM high percentile # %end # %option @@ -140,8 +124,7 @@ # %option G_OPT_V_OUTPUT # % key: output_vegetation -# % required: yes -# % label: Name of output roof vegetation vector map +# % label: Name for output roof vegetation vector map # %end # %option G_OPT_MEMORYMB diff --git a/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs/r.extract.greenroofs.py b/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs/r.extract.greenroofs.py index 89a55f9..dcdf25c 100644 --- a/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs/r.extract.greenroofs.py +++ b/grass-gis-addons/m.analyse.buildings/r.extract.greenroofs/r.extract.greenroofs.py @@ -23,98 +23,91 @@ # % keyword: classification # % keyword: statistics # % keyword: buildings analysis -# % keyword: greenroofs +# % keyword: green roofs # %end # %option G_OPT_R_INPUT # % key: ndsm -# % type: string -# % required: yes # % label: Name of the nDSM raster +# % answer: ndsm # % guisection: Input # %end # %option G_OPT_R_INPUT # % key: ndvi -# % type: string -# % required: yes # % label: Name of the NDVI raster +# % answer: dop_ndvi_05 # % guisection: Input # %end # %option G_OPT_R_INPUT # % key: red -# % type: string -# % required: yes # % label: Name of the red DOP raster +# % answer: dop_red_05 # % guisection: Input # %end # %option G_OPT_R_INPUT # % key: green -# % type: string -# % required: yes # % label: Name of the green DOP raster +# % answer: dop_green_05 # % guisection: Input # %end # %option G_OPT_R_INPUT # % key: blue -# % type: string -# % required: yes # % label: Name of the blue DOP raster +# % answer: dop_blue_05 # % guisection: Input # %end # %option G_OPT_V_INPUT # % key: fnk -# % type: string # % required: no -# % label: Vector map containing Flaechennutzungskartierung +# % label: Name of vector map containing the Flaechennutzungskartierung # % guisection: Optional input # % guidependency: fnk_column # %end # %option G_OPT_DB_COLUMN # % key: fnk_column -# % type: string -# % required: no -# % multiple: no -# % label: Integer column containing FNK-code +# % label: Name of integer column containing FNK-code # % guisection: Optional input # %end # %option G_OPT_V_INPUT # % key: buildings -# % type: string -# % required: yes -# % label: Vector map containing outlines of buildings +# % label: Name of vector map containing outlines of buildings +# % answer: building_outlines # % guisection: Input # %end # %option G_OPT_V_INPUT # % key: trees -# % type: string # % required: no # % label: Vector map containing tree polygons # % guisection: Optional input # %end # %option -# % key: gb_thresh +# % key: gb_perc # % type: integer # % required: no # % multiple: no -# % label: Define fix Green-Blue-Ratio threshold (on a scale from 0-255) +# % label: Green-Blue-Ratio percentile in green areas to use for thresholding +# TODO: make radio button and add default +# # % answer: 25 # % guisection: Parameters # %end # %option -# % key: gb_perc +# % key: gb_thresh # % type: integer # % required: no # % multiple: no -# % label: Define Green-Blue-Ratio threshold as this percentile of green areas +# % label: Fix Green-Blue-Ratio threshold (on a scale from 0-255) +# TODO: make radio button and add default +# # % answer: 145 # % guisection: Parameters # %end @@ -140,15 +133,15 @@ # %option G_OPT_V_OUTPUT # % key: output_buildings -# % required: yes -# % label: Name of output building vector map +# % label: Name for output buildings vector map +# % answer: buildings_with_green_roofs # % guisection: Output # %end # %option G_OPT_V_OUTPUT # % key: output_vegetation -# % required: yes -# % label: Name of output roof vegetation vector map +# % label: Name for output roof vegetation vector map +# % answer: green_roofs # % guisection: Output # %end diff --git a/grass-gis-addons/m.analyse.buildings/v.cd.areas.worker/v.cd.areas.worker.py b/grass-gis-addons/m.analyse.buildings/v.cd.areas.worker/v.cd.areas.worker.py index 11f270e..03186de 100644 --- a/grass-gis-addons/m.analyse.buildings/v.cd.areas.worker/v.cd.areas.worker.py +++ b/grass-gis-addons/m.analyse.buildings/v.cd.areas.worker/v.cd.areas.worker.py @@ -26,6 +26,11 @@ # % keyword: worker # %end +# %option G_OPT_V_INPUT +# % key: area +# % description: Input natural tiles as vector map +# %end + # %option # % key: new_mapset # % type: string @@ -35,11 +40,6 @@ # % description: Name for new mapset # %end -# %option G_OPT_V_INPUT -# % key: area -# % description: Input natural tiles as vector map -# %end - # %option G_OPT_V_INPUT # %label: Name of the input vector layer # %end diff --git a/grass-gis-addons/m.analyse.buildings/v.cd.areas/v.cd.areas.py b/grass-gis-addons/m.analyse.buildings/v.cd.areas/v.cd.areas.py index 5cfa186..f6328c4 100644 --- a/grass-gis-addons/m.analyse.buildings/v.cd.areas/v.cd.areas.py +++ b/grass-gis-addons/m.analyse.buildings/v.cd.areas/v.cd.areas.py @@ -28,19 +28,21 @@ # %option G_OPT_V_INPUT # %label: Name of the input vector layer +# % answer: buildings # % guisection: Input # %end # %option G_OPT_V_INPUT # % key: reference # % label: Name of the reference vector layer +# % answer: reference_buildings # % guisection: Input # %end # %option # % key: min_size # % type: integer -# % required: no +# % required: yes # % multiple: no # % label: Minimum size of identified change areas in sqm # % answer: 5 @@ -50,7 +52,7 @@ # %option # % key: max_fd # % type: double -# % required: no +# % required: yes # % multiple: no # % label: Maximum value of fractal dimension of identified change areas (see v.to.db) # % answer: 2.5 @@ -58,6 +60,7 @@ # %end # %option G_OPT_V_OUTPUT +# % answer: buildings_difference # % guisection: Output # %end @@ -467,7 +470,7 @@ def main(): keepcols = ("cat", "floors", area_col, fd_col, "source") clean_columns(map=cd_output, keepcolumns=keepcols) - grass.message(_(f"Created output vector map <{cd_output}>")) + grass.message(_(f"Created output vector map <{cd_output}>.")) if flags["q"]: # quality assessment: calculate completeness and correctness