fix bug in Vector2Raster
@@ -200,11 +200,15 @@ class VectorToRaster(EOTask):
if eopatch.bbox is None:
raise ValueError('EOPatch has to have a bounding box')
+ feature_type, feature_name = self.raster_feature
+ height, width = self._get_raster_shape(eopatch)
+
rasterization_shapes = self._get_rasterization_shapes(eopatch)
if not rasterization_shapes:
+ eopatch[feature_type][feature_name] = \
+ np.full((height, width), self.no_data_value)[..., np.newaxis].astype(self.raster_dtype)
return eopatch
- height, width = self._get_raster_shape(eopatch)
affine_transform = rasterio.transform.from_bounds(*eopatch.bbox, width=width, height=height)
raster = self._get_raster(eopatch, height, width)
@@ -212,7 +216,6 @@ class VectorToRaster(EOTask):
rasterio.features.rasterize(rasterization_shapes, out=raster, transform=affine_transform,
dtype=self.raster_dtype, **self.rasterio_params)
- feature_type, feature_name = self.raster_feature
eopatch[feature_type][feature_name] = raster[..., np.newaxis]
return eopatch
