Skip to content

Commit

Permalink
changes for using gui
Browse files Browse the repository at this point in the history
  • Loading branch information
juleshaas committed Jan 4, 2024
1 parent 813958f commit ab4935b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENV GRASS_ADDON_BASE=/usr/local/grass84

# install external dependencies
# RUN apt install musl-dev ??
RUN pip3 install py7zr tqdm requests psutil scikit-learn pyproj
RUN pip3 install py7zr tqdm requests psutil scikit-learn pyproj pandas

# install official addons
RUN grass --tmp-location EPSG:4326 --exec g.extension r.mapcalc.tiled -s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def main():
except Exception:
grass.fatal("m.analyse.trees library is not installed")

area = options["area"]
group = options["group"]
area = options["area"].split("@")[0]
group = options["group"].split("@")[0]
output = options["output"]
model = options["model"]
new_mapset = options["new_mapset"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def main():
blue = options["blue_raster"]
nir = options["nir_raster"]
ndvi = options["ndvi_raster"]
ndvi_split = ndvi.split('@')[0]
ndwi = options["ndwi_raster"]
ndgb = options["ndgb_raster"]
ndsm = options["ndsm"]
Expand Down Expand Up @@ -284,50 +285,50 @@ def main():
grass.run_command(
"r.neighbors",
input=ndvi,
output=f"{ndvi}_min1",
output=f"{ndvi_split}_min1",
size=3,
method="minimum",
nprocs=nprocs,
memory=memory_max100mb,
)
grass.run_command(
"r.neighbors",
input=f"{ndvi}_min1",
output=f"{ndvi}_min2",
input=f"{ndvi_split}_min1",
output=f"{ndvi_split}_min2",
size=3,
method="minimum",
nprocs=nprocs,
memory=memory_max100mb,
)
grass.run_command(
"r.neighbors",
input=f"{ndvi}_min2",
output=f"{ndvi}_max1",
input=f"{ndvi_split}_min2",
output=f"{ndvi_split}_max1",
size=3,
method="maximum",
nprocs=nprocs,
memory=memory_max100mb,
)
grass.run_command(
"r.neighbors",
input=f"{ndvi}_max1",
output=f"{ndvi}_max2",
input=f"{ndvi_split}_max1",
output=f"{ndvi_split}_max2",
size=3,
method="maximum",
nprocs=nprocs,
memory=memory_max100mb,
)
rm_rasters.append(f"{ndvi}_min1")
rm_rasters.append(f"{ndvi}_min2")
rm_rasters.append(f"{ndvi}_max1")
rm_rasters.append(f"{ndvi}_max2")
rm_rasters.append(f"{ndvi_split}_min1")
rm_rasters.append(f"{ndvi_split}_min2")
rm_rasters.append(f"{ndvi_split}_max1")
rm_rasters.append(f"{ndvi_split}_max2")

grass.mapcalc(
f"trees_ml_nearest = if({tree_pixels} == 2, {nearest}, null())"
)
rm_rasters.append("trees_ml_nearest")
grass.mapcalc(
f"trees_ml_pixel_ndvi = if({ndvi}_max2 < {ndvi_threshold}, null(), trees_ml_nearest)"
f"trees_ml_pixel_ndvi = if({ndvi_split}_max2 < {ndvi_threshold}, null(), trees_ml_nearest)"
)
rm_rasters.append("trees_ml_pixel_ndvi")

Expand Down Expand Up @@ -441,7 +442,7 @@ def main():
grass.run_command(
"r.stats.zonal",
base="trees_ml_object_ndsm",
cover=f"{ndvi}_max2",
cover=f"{ndvi_split}_max2",
method="average",
output="trees_ml_object_ndviavg",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# %option G_OPT_R_INPUT
# % key: ndom
# % label: Raster map of nDOM
# % label: Raster map of nDSM
# % required: no
# % guisection: Input
# %end
Expand Down Expand Up @@ -135,7 +135,7 @@ def main():

pid = os.getpid()

treecrowns = options["treecrowns"]
treecrowns = options["treecrowns"].split("@")[0]
ndom = options["ndom"]
ndvi = options["ndvi"]
buildings = options["buildings"]
Expand Down Expand Up @@ -289,6 +289,7 @@ def main():
if nprocs > 1:
for subset_name, mapset_name in zip(subset_names, mapset_names):
treecrown_subset_mapset.append(f"{subset_name}@{mapset_name}")
grass.message(len(mapset_names))
grass.run_command(
"v.patch",
input=treecrown_subset_mapset,
Expand Down

0 comments on commit ab4935b

Please sign in to comment.