georasters icon indicating copy to clipboard operation
georasters copied to clipboard

Open file and immediately save it makes exception

Open culebron opened this issue 7 years ago • 3 comments

I open ASTER DEM file with such simple code: ds = gr.from_file(input_file) ds.to_tiff('/tmp/test')

And it makes exception:

  File "store_gridfs.py", line 13, in main
ds.to_tiff('/tmp/test')
  File ".../georasters.py", line 478, in to_tiff
self.raster.data[self.raster.mask] = self.nodata_value
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

I tried shielding it with an if closure, but then it made another exception:

  File ".../georasters.py", line 122, in create_geotiff
    if isinstance(datatype, np.int) == False:
  File "/usr/local/lib/python3.6/dist-packages/numpy/ma/core.py", line 3353, in __setitem__
    _data[indx] = dval

You usually expect open and save methods to work seamlessly.

culebron avatar Mar 20 '18 12:03 culebron

In #33 , I added checks of masked data length and converting ndv to double. But check if it works in earlier python versions.

culebron avatar Mar 20 '18 12:03 culebron

I wonder if this is related to #28? What do you get when requesting ds.nodata_value? I thought about forcing a NDV on the raster fi missing, but that may cause issues so perhaps it would be best to just add an error message that is more informative.

ozak avatar Mar 20 '18 13:03 ozak

@culebron were you able to test this (#33)? Or can you share the file you were using?

ozak avatar May 28 '20 21:05 ozak