diff --git a/HISTORY.rst b/HISTORY.rst index db147f94d..333b91975 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -100,6 +100,10 @@ Unreleased Changes * Fixed a bug where the model incorrectly raised an error if the biophysical table contained a row of all 0s. (`#1123 `_) +* Urban Nature Access + * Fixed an issue where, under certain circumstances, the model would raise + a cryptic ``TypeError`` when creating the summary vector. + https://github.com/natcap/invest/issues/1350 * Visitation: Recreation and Tourism * Fixed a bug where overlapping predictor polygons would be double-counted in ``polygon_area_coverage`` and ``polygon_percent_coverage`` calculations. diff --git a/src/natcap/invest/urban_nature_access.py b/src/natcap/invest/urban_nature_access.py index 48b4ae703..113a1e5b3 100644 --- a/src/natcap/invest/urban_nature_access.py +++ b/src/natcap/invest/urban_nature_access.py @@ -2014,7 +2014,10 @@ def _write_supply_demand_vector(source_aoi_vector_path, feature_attrs, for feature in target_layer: feature_id = feature.GetFID() for attr_name, attr_value in feature_attrs[feature_id].items(): - feature.SetField(attr_name, attr_value) + # It is possible that attr_value may be a numpy.float32 object, + # which will raise a cryptic error. Numpy.float64 will not raise + # this error. Casting to float avoids the issue. + feature.SetField(attr_name, float(attr_value)) target_layer.SetFeature(feature) target_layer.CommitTransaction()