-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
# This script shows how the building and greenroof detection could be done | ||
# with a shell script according to the documentation with default values. | ||
# Author: RVR | ||
# Date: 06.10.2023 | ||
# Version: 1.0.0 | ||
|
||
# Create a new mapset for the analysis | ||
g.mapset -c example_mapset | ||
|
||
# Declare a variable for the data folder | ||
DATAFOLDER=/mnt/data | ||
|
||
# Start import process for building detection | ||
# Change file names and paths accordingly | ||
m.import.rvr type=gebaeudedetektion \ | ||
area=${DATAFOLDER}/AOI/AOI.gpkg \ | ||
fnk_file=${DATAFOLDER}/FNK/FNK.gpkg fnk_column=codeXY \ | ||
reference_buildings_file=${DATAFOLDER}/ALKIS/ALKIS.gpkg \ | ||
dop_dir=${DATAFOLDER}/DOP/ \ | ||
dop_tindex=${DATAFOLDER}/dop_tindex.gpkg \ | ||
dsm_dir=${DATAFOLDER}/2_5D/ \ | ||
dsm_tindex=${DATAFOLDER}/dsm_tindex.gpkg \ | ||
dtm_file=${DATAFOLDER}/DGM1/DGM1_corrected.tif \ | ||
memory=300 \ | ||
nprocs=-2 | ||
|
||
# Set region | ||
g.region rast=dop_red_05 -p | ||
|
||
# Start building detection with ndvi_thresh | ||
r.extract.buildings \ | ||
ndsm=ndsm \ | ||
ndvi_raster=dop_ndvi_05 \ | ||
fnk_vector=fnk fnk_column=codeXY \ | ||
ndvi_thresh=145 \ | ||
output=buildings \ | ||
memory=300 \ | ||
nprocs=-2 \ | ||
tile_size=1000 | ||
|
||
# Set region | ||
g.region rast=dop_red_05 -p | ||
|
||
# Start change detection with quality measures | ||
v.cd.areas -q \ | ||
input=buildings \ | ||
reference=reference_buildings \ | ||
min_size=5 \ | ||
max_fd=2.5 \ | ||
output=buildings_alkis_difference \ | ||
nprocs=-2 \ | ||
tile_size=1000 | ||
|
||
# Export building results | ||
v.out.ogr input=buildings output=/results/buildings.gpkg format=GPKG | ||
v.out.ogr input=buildings_alkis_difference output=/results/buildings_alkis_difference.gpkg format=GPKG | ||
|
||
# Import trees for greenroof detection | ||
# Already imported data will be skipped | ||
m.import.rvr type=dachbegruenung \ | ||
area=${DATAFOLDER}/AOI/E_Bredeney_gmk_nrw.gpkg \ | ||
building_outlines_file=/results/buildings.gpkg \ | ||
tree_file=${DATAFOLDER}/trees.gpkg \ | ||
dop_dir=${DATAFOLDER}/DOP/ \ | ||
dop_tindex=${DATAFOLDER}/dop_tindex.gpkg \ | ||
dsm_dir=${DATAFOLDER}/2_5D/ \ | ||
dsm_tindex=${DATAFOLDER}/dsm_tindex.gpkg \ | ||
dtm_file=${DATAFOLDER}/DGM1/DGM1_corrected.tif \ | ||
memory=300 \ | ||
nprocs=-2 | ||
|
||
# Set region | ||
g.region rast=dop_red_05 -p | ||
|
||
# Start import process for greenroof detection | ||
# with detected buildings, gb_thresh and | ||
# segmentation | ||
r.extract.greenroofs -s \ | ||
ndsm=ndsm \ | ||
ndvi=dop_ndvi_05 \ | ||
red=dop_red_05 green=dop_green_05 blue=dop_blue_05 \ | ||
buildings=building_outlines \ | ||
trees=trees \ | ||
gb_thresh=145 \ | ||
min_veg_size=5 \ | ||
min_veg_proportion=10 \ | ||
output_buildings=begruente_gebaeude \ | ||
output_vegetation=dachgruen \ | ||
memory=300 \ | ||
nprocs=-2 \ | ||
tile_size=1000 | ||
|
||
# Export greeenroof results | ||
v.out.ogr input=begruente_gebaeude output=/results/begruente_gebaeude.gpkg format=GPKG | ||
v.out.ogr input=dachgruen output=/results/dachgruen.gpkg format=GPKG | ||
|
||
# Export raster data | ||
r.out.gdal input=dop_ndvi_05 output=/results/ndvi_05.tif format=GTiff createopt="COMPRESS=DEFLATE" | ||
r.out.gdal input=ndsm output=/results/ndsm_05.tif format=GTiff createopt="COMPRESS=DEFLATE" | ||
r.out.gdal input=dsm_05 output=/results/dsm_05.tif format=GTiff createopt="COMPRESS=DEFLATE" | ||
r.out.gdal input=dtm_05 output=/results/dtm_05.tif format=GTiff createopt="COMPRESS=DEFLATE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Screen can be used to run the tool in the background | ||
# and close the terminal window. Very useful when working with | ||
# external servers. | ||
|
||
# Start screen session with terminal | ||
screen -RD session_name | ||
|
||
# Start docker container | ||
# Docker file needs to be pulled first according to documentation | ||
docker run -it -v /path/to/local/folder/grassdb:/grassdb -v /path/to/local/folder/data:/mnt/data -v /path/to/local/folder/results:/results rvr_interface:latest sh | ||
|
||
# Start grass and create new location | ||
grass -c epsg:25832 /grassdb/location_25832 | ||
|
||
# OR start existing location in mapset PERMANENT | ||
grass /grassdb/haus_location_25832/PERMANENT | ||
|
||
# Run sh-script example | ||
sh /path/to/script/in/docker/extract_buildings_example.sh | ||
|
||
# Detach terminal | ||
# See screen manual for short cuts | ||
ctrl+A, D | ||
|
||
# Open session again | ||
screen -rd session_name | ||
|
||
# Close session permanetly after analysis | ||
exit |