Skip to content

Commit

Permalink
Casting the value to a float before we set it. RE:natcap#1343
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Aug 15, 2023
1 parent 97403ac commit b9a10f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/natcap/invest/urban_nature_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,9 @@ def _write_supply_demand_vector(source_aoi_vector_path, feature_attrs,
feature_id = feature.GetFID()
for attr_name, attr_value in feature_attrs[feature_id].items():
try:
feature.SetField(attr_name, attr_value)
# GDAL won't accept numpy float32 values, so avoid this
# possibility by casting to a float.
feature.SetField(attr_name, float(attr_value))
except TypeError:
LOGGER.exception(
f"Could not set attribute {attr_name} to {attr_value} "
Expand Down

0 comments on commit b9a10f7

Please sign in to comment.