Skip to content

Commit

Permalink
Merge pull request #4 from mundialis/unique_suffix
Browse files Browse the repository at this point in the history
m.neural_network.preparedata: Add option for a suffix
  • Loading branch information
griembauer authored Jan 15, 2025
2 parents fbd041a + 617ebce commit b70aca4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ <h2>DESCRIPTION</h2>
training data preparation of a neural network using DOPs and nDSM as input data. Additionally,
a tile index containing information about the labeled status is created.

<p>The <em>suffix</em> option may be used to add a suffix to each output tile/file in order to create unique tile IDs that can later be combined with results from other runs.</p>

<h2>EXAMPLES</h2>

<h3>Prepare the labeling of training data for a neural network with a tile_size of 512</h3>
Expand Down
13 changes: 13 additions & 0 deletions m.neural_network.preparedata/m.neural_network.preparedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@
# % guisection: Optional input
# %end

# %option
# % key: suffix
# % type: string
# % required: no
# % label: Suffix to be added to each output file
# % description: Use the suffix to provide a unique ID for e.g. a specific flight campaign year
# % guisection: Optional input
# %end

# %option G_OPT_M_DIR
# % key: output_dir
# % multiple: no
Expand Down Expand Up @@ -186,6 +195,8 @@ def main() -> None:
train_percentage = int(options["train_percentage"])
output_dir = options["output_dir"]
nprocs = set_nprocs(int(options["nprocs"]))
if options["suffix"]:
suffix = options["suffix"]

# get addon etc path
etc_path = get_lib_path(modname="m.neural_network.preparedata")
Expand Down Expand Up @@ -244,6 +255,8 @@ def main() -> None:
col_str = str(col).zfill(num_zeros)
tile_id = f"{row_str}{col_str}"
tile_name = f"tile_{row_str}_{col_str}"
if options["suffix"]:
tile_name += f"_{suffix}"
new_mapset = f"tmp_mapset_{ID}_{tile_id}"
rm_dirs.append(os.path.join(gisdbase, location, new_mapset))

Expand Down

0 comments on commit b70aca4

Please sign in to comment.