CONABIO / antares3

Madmex with open data cube and in python3
2 stars 2 forks source link

check type when using db_to_raster command #39

Open palmoreck opened 6 years ago

palmoreck commented 6 years ago

In

https://github.com/CONABIO/antares3/blob/develop/madmex/management/commands/db_to_raster.py#L148

and

https://github.com/CONABIO/antares3/blob/develop/madmex/management/commands/db_to_raster.py#L156

there's a default value: np.uint8 which for scheme classification values out of range [0,255] will raise an error:

...
  File "/usr/local/lib/python3.5/dist-packages/rasterio/features.py", line 287, in rasterize
    raise ValueError(format_cast_error('shape values', dtype))
ValueError: shape values cannot be cast to specified dtype: <class 'numpy.uint8'>

so, handle this either in db_to_raster or ingest_training command

(error got when using scheme of classes for colombia workshop, some values were: 321113, 2121, ...)