The GeoRaster2.limit_to_bands method behaves differently depending on whether _image has been already read or not:
def limit_to_bands(self, bands):
if self._image is not None:
bands_data = self.bands_data(bands)
return self.copy_with(image=bands_data, band_names=bands)
else:
indices = self.bands_indices(bands)
bidxs = map(lambda idx: idx + 1, indices)
doc = boundless_vrt_doc(self._raster_opener(self.source_file), bands=bidxs)
filename = self._save_to_destination_file(doc.tostring())
return self.__class__(filename=filename, band_names=bands)
When dealing with a MutableGeoraster instance this provokes that depending on this condition the returned type is MutableGeoRaster or GeoRaster2:
In [2]: img = GeoRaster2.open("whatever.tif", lazy_load=False, mutable=True)
In [5]: band = img.limit_to_bands(["raw"])
In [6]: type(band)
Out[6]: telluric.georaster.GeoRaster2
In [7]: img = GeoRaster2.open("whatever.tif", mutable=True)
In [8]: band = img.limit_to_bands(["raw"])
In [9]: type(band)
Out[9]: telluric.georaster.MutableGeoRaster
I made MutableGeoRaster implement the limit_to_bands method. This could also be accomplished modifying the base method but I don't know if Georaster2 class should know about its childs. What do you think?
The
GeoRaster2.limit_to_bands
method behaves differently depending on whether_image
has been already read or not:When dealing with a
MutableGeoraster
instance this provokes that depending on this condition the returned type isMutableGeoRaster
orGeoRaster2
:I made
MutableGeoRaster
implement thelimit_to_bands
method. This could also be accomplished modifying the base method but I don't know ifGeoraster2
class should know about its childs. What do you think?