Skip to content

Commit

Permalink
Merge pull request #1134 from dcdenu4/task/1133-pgp-get-gis-type-change
Browse files Browse the repository at this point in the history
Update for new get_gis_type behavior
  • Loading branch information
phargogh authored Dec 14, 2022
2 parents 24a954b + c81205c commit 43d38d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ numpy>=1.11.0,!=1.16.0
Rtree>=0.8.2,!=0.9.1
shapely>=1.7.1,<1.8.2 # https://github.com/shapely/shapely/issues/1385
scipy>=1.9.0
pygeoprocessing>=2.3.2 # pip-only
pygeoprocessing>=2.3.5 # pip-only
taskgraph[niced_processes]>=0.11.0 # pip-only
psutil>=5.6.6
chardet>=3.0.4
Expand Down
4 changes: 2 additions & 2 deletions src/natcap/invest/habitat_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def _validate_threat_path(threat_path, lulc_key):
"""
# Checking threat path exists to control custom error messages
# for user readability.
if os.path.exists(threat_path):
try:
threat_gis_type = pygeoprocessing.get_gis_type(threat_path)
if threat_gis_type != pygeoprocessing.RASTER_TYPE:
# Raise a value error with custom message to help users
Expand All @@ -1045,7 +1045,7 @@ def _validate_threat_path(threat_path, lulc_key):
return None
else:
return threat_path
else:
except ValueError:
if lulc_key != '_b':
return "error"
else:
Expand Down
12 changes: 3 additions & 9 deletions src/natcap/invest/hra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,17 +1956,11 @@ def _parse_criteria_table(criteria_table_path, target_composite_csv_path):
# to a raster or vector.
attribute_value = utils.expand_path(
attribute_value, criteria_table_path)
spatial_file_ok = True

try:
if (pygeoprocessing.get_gis_type(attribute_value) ==
pygeoprocessing.UNKNOWN_TYPE):
# File is not a spatial file
spatial_file_ok = False
_ = pygeoprocessing.get_gis_type(attribute_value)
except ValueError:
# file not found
spatial_file_ok = False

if not spatial_file_ok:
# File is not a spatial file or file not found
raise ValueError(
"Criterion could not be opened as a spatial "
f"file {attribute_value}")
Expand Down

0 comments on commit 43d38d4

Please sign in to comment.