telluric icon indicating copy to clipboard operation
telluric copied to clipboard

Getting histogram fails

Open drnextgis opened this issue 6 years ago • 2 comments

In [1]: import telluric as tl

In [2]: rr  = tl.GeoRaster2.open('tests/data/raster/rgb.tif')

In [3]: rr.histogram()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-3c91277270c7> in <module>()
----> 1 rr.histogram()

~/sandbox/telluric/telluric/telluric/georaster.py in histogram(self)
   1193 
   1194     def histogram(self):
-> 1195         histogram = {band: self._histogram(band) for band in self.band_names}
   1196         return Histogram(histogram)
   1197 

~/sandbox/telluric/telluric/telluric/georaster.py in <dictcomp>(.0)
   1193 
   1194     def histogram(self):
-> 1195         histogram = {band: self._histogram(band) for band in self.band_names}
   1196         return Histogram(histogram)
   1197 

~/sandbox/telluric/telluric/telluric/georaster.py in _histogram(self, band)
   1204             raise GeoRaster2NotImplementedError('cant calculate histogram for type %s' % self.image.dtype)
   1205 
-> 1206         band_image = self.limit_to_bands(band).image
   1207         return np.histogram(band_image[~band_image.mask], range=(0, length), bins=length)[0]
   1208 

~/sandbox/telluric/telluric/telluric/georaster.py in limit_to_bands(self, bands)
   1082 
   1083     def limit_to_bands(self, bands):
-> 1084         subimage = self.subimage(bands)
   1085         return self.copy_with(image=subimage, band_names=bands)
   1086 

~/sandbox/telluric/telluric/telluric/georaster.py in subimage(self, bands)
    387             bands = bands.split(",")
    388 
--> 389         missing_bands = set(bands) - set(self.band_names)
    390         if missing_bands:
    391             raise GeoRaster2Error('requested bands %s that are not found in raster' % missing_bands)

TypeError: 'int' object is not iterable

drnextgis avatar Jun 03 '18 18:06 drnextgis

Are band names supposed to be list of strings? Then we should have something like this:

return list(map(str, self._band_names))

here: https://github.com/satellogic/telluric/blob/87c203b875908a0e20c0cd06adcc1f0a034b1b1d/telluric/georaster.py#L523

drnextgis avatar Jun 12 '18 05:06 drnextgis

The histograms part is in a sorry state at the moment. Let's talk to @slava-kerner and @arielze to do some cleanup there. They are also related to the stretch_histogram functionality that you touched in #66.

astrojuanlu avatar Jun 29 '18 11:06 astrojuanlu