Skip to content

Commit

Permalink
correctly applying bounding, adjacency return type
Browse files Browse the repository at this point in the history
  • Loading branch information
jsta committed Mar 12, 2024
1 parent e93d721 commit 48c4a61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions hydropop/dev/end_to_end_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
target_hpu_size = 300 # in pixels - not guaranteed, but will try to make each HPU this size

## Path parameters
path_bounding_box = r"data/roi.gpkg" # shapefile of ROI
path_bounding_box = r"data/roi_small.gpkg" # r"data/roi.gpkg"
path_results = r'results' # folder to store results
run_name = 'toronto_new_method' # string to prepend to exports
gee_asset = 'projects/cimmid/assets/toronto_coarse_hpus' # the asset path to the hydropop shapefile--this might not be known beforehand but is created upon asset loading to GEE
Expand All @@ -42,7 +42,7 @@

""" Generate HPUs """
# Instantiate hpu class - can take awhile to load images and do some preprocessing
hpugen = hpc.hpu(path_pop, path_hthi, path_bounding_box)
hpugen = hpc.hpu(path_pop, path_hthi, bounding=path_bounding_box)

# Compute classes
breaks = {'hthi':hthi_breaks, 'pop':pop_breaks}
Expand All @@ -55,8 +55,8 @@
hpugen.compute_hpus(target_hpu_size, min_hpu_size)

# Export adjacency
hpugen.compute_adjacency()
hpugen.adjacency.to_csv(paths['adjacency'], index=False)
adj_df = hpugen.compute_adjacency()
adj_df.to_csv(paths['adjacency'], index=False)

# Export HPU rasters
hpugen.export_raster('hpu_simplified', paths['hpu_raster'])
Expand Down
3 changes: 2 additions & 1 deletion hydropop/hp_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import json
import tqdm
import scipy
import platform
import subprocess
Expand Down Expand Up @@ -1067,7 +1068,7 @@ def create_hpus_from_classes(Iclasses, target_n_pix):
"""

rp, Ilabeled = ru._regionprops(Iclasses, props=['coords', 'area'])
rp, _ = ru._regionprops(Iclasses, props=['coords', 'area'])
Iregions = np.ones(Iclasses.shape, dtype=int) * -1
reg_label = 1
for area, coords in zip(rp['area'], rp['coords']):
Expand Down

0 comments on commit 48c4a61

Please sign in to comment.