osgeonepal / geotile

GeoTile is the python library for tiling the geographic raster data (eg. Tiff etc)
https://geotile.readthedocs.io
MIT License
74 stars 9 forks source link

Given nodata value, -32768.0, is beyond the valid range of its data type, uint8. #68

Closed iamtekson closed 8 months ago

iamtekson commented 8 months ago

This error message is similar to #64 and #56. I think, we need to pass the nodata as a parameter.

File ~/miniconda3/envs/tf212/lib/python3.9/site-packages/geotile/GeoTile.py:476, in GeoTile.save_tiles(self, output_folder, prefix, suffix, image_format, dtype)
    473 meta.update({"count": wd.shape[0]})
    475 # save the tiles with new metadata
--> 476 with rio.open(tile_path, "w", **meta) as outds:
    477     outds.write(wd.astype(meta["dtype"]))

File ~/miniconda3/envs/tf212/lib/python3.9/site-packages/rasterio/env.py:451, in ensure_env_with_credentials.<locals>.wrapper(*args, **kwds)
    448     session = DummySession()
    450 with env_ctor(session=session):
--> 451     return f(*args, **kwds)

File ~/miniconda3/envs/tf212/lib/python3.9/site-packages/rasterio/__init__.py:314, in open(fp, mode, driver, width, height, count, crs, transform, dtype, nodata, sharing, **kwargs)
    312 writer = get_writer_for_driver(driver)
    313 if writer is not None:
--> 314     dataset = writer(
    315         path,
    316         mode,
    317         driver=driver,
    318         width=width,
    319         height=height,
    320         count=count,
    321         crs=crs,
    322         transform=transform,
    323         dtype=dtype,
    324         nodata=nodata,
    325         sharing=sharing,
    326         **kwargs
    327     )
    328 else:
    329     raise DriverCapabilityError(
    330         "Writer does not exist for driver: %s" % str(driver)
    331     )

File rasterio/_io.pyx:1502, in rasterio._io.DatasetWriterBase.__init__()

ValueError: Given nodata value, -32768.0, is beyond the valid range of its data type, uint8.