Skip to content

Commit

Permalink
rasterization bug fixed #39
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtekson committed Sep 26, 2023
1 parent c3ca843 commit 8a9aecb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
19 changes: 1 addition & 18 deletions geotile/GeoTile.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ def rasterization(
out_path: str,
value_col=None,
no_data: Optional[int] = None,
fill: Optional[int] = 0,
**kwargs,
):
"""Convert vector shapes into raster
Expand All @@ -658,9 +657,7 @@ def rasterization(
If None, the rasterization will be binary otherwise the rasterization will be the based on value of the column
no_data: int
The no data value of the raster.
If None, the no data value of the raster will be the same as the input raster
fill: int
The fill value of the raster (e.g. 0)
Default value is None.
kwargs: dict
# rasterio.rasterize.rasterize (e.g. fill, transform etc.)
The kwargs from rasterio.rasterize can be used here: https://rasterio.readthedocs.io/en/latest/api/rasterio.rasterize.html
Expand Down Expand Up @@ -695,24 +692,10 @@ def rasterization(
dataset,
self.ds.shape,
transform=self.meta["transform"],
fill=fill,
**kwargs,
)
mask = np.reshape(mask, (1, mask.shape[0], mask.shape[1]))

# if no_data_val is None, use the nodata value from the raster
if no_data_val is None:
no_data_val = self.meta["nodata"]

# if the dtype is float, set the no data value to 0
if (
(self.meta["nodata"] == np.nan)
and (no_data_val is None)
and (self.get_dtype(mask) not in _int_dtypes)
):
print("The dtype of the raster is float, setting the no data value to 0")
no_data_val = 0 # if the dtype is float, set the no data value to 0

# update the metadata
meta = self.meta.copy()
meta.update({"count": 1, "dtype": self.get_dtype(mask), "nodata": no_data})
Expand Down
2 changes: 1 addition & 1 deletion geotile/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__author__ = "Tek Kshetri"
__email__ = "[email protected]"
__version__ = "1.0.3"
__version__ = "1.0.4"

0 comments on commit 8a9aecb

Please sign in to comment.