Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschwenk committed Feb 22, 2024
1 parent b0da719 commit 7ec0764
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Binary file modified hydropop/__pycache__/hp_class.cpython-38.pyc
Binary file not shown.
Binary file modified hydropop/__pycache__/hp_utils.cpython-38.pyc
Binary file not shown.
17 changes: 13 additions & 4 deletions hydropop/hp_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
@author: Jon
"""
import numpy as np
import sys
import pandas as pd
import geopandas as gpd
sys.path.append(r'X:\Research\DR Reserve\Code')
import hp_utils as hut
import plotting_utils as pu
import hydropop.hp_utils as hut
import rivgraph.io_utils as io
from osgeo import gdal
import os
Expand Down Expand Up @@ -139,6 +136,18 @@ def compute_hp_classes_ranges(self, breaks={'pop':[-100, -4, -2, -1, 0, 1, 100],
# Set masked class values to 0
# self.I['hpu_class'][self.I['mask']] = 0
self.class_map = dmap

# Format the class map
rows = ['HTHI_mean', 'pop_dens_mean', 'HTHI_min', 'HTHI_max', 'pop_dens_min', 'pop_dens_max']
cmf = pd.DataFrame(index=rows, columns=sorted(list(self.class_map.keys())))
for c in self.class_map:
cmf.at['HTHI_mean', c] = (self.class_map[c][2] + self.class_map[c][3])/2
cmf.at['pop_dens_mean', c] = (self.class_map[c][0] + self.class_map[c][1])/2
cmf.at['HTHI_min', c] = self.class_map[c][2]
cmf.at['pop_dens_min', c] = self.class_map[c][0]
cmf.at['HTHI_max', c] = self.class_map[c][3]
cmf.at['pop_dens_max', c] = self.class_map[c][1]
self.class_map_formatted = cmf


def simplify_hpu_classes(self, min_class_size=4, nodata=0, maxiter=10, unique_neighbor=False):
Expand Down
7 changes: 2 additions & 5 deletions hydropop/hp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
env: hp
"""
import sys
import os
sys.path.append(r'C:\Users\Jon\Desktop\Research\DR Reserve\Code')
from osgeo import gdal, osr, ogr
from osgeo import gdal, ogr
import subprocess
import platform
import numpy as np
import pandas as pd
import geopandas as gpd
from pyproj import CRS
from shapely.geometry import Polygon, MultiPolygon
from shapely.geometry import shape
from shapely.geometry import MultiPolygon, shape
from shapely.validation import make_valid
from shapely.ops import unary_union
import json
Expand Down

0 comments on commit 7ec0764

Please sign in to comment.