I am using snappy for processing SAR data, but it seems that snappy uses its own 'product' objects for storing raster data. But i only need the resulting array of pixel values after I finish working with it. How can I retrieve such array from speckle
variable in the code below?
import snappy
import pathlib
from configparser import ConfigParser
import os
config = ConfigParser()
config.read('config.ini')
projLibPath = config['PATHS']['proj_lib']
gdalDataPath = config['PATHS']['gdal_data']
os.environ['PROJ_LIB'] = projLibPath
os.environ['GDAL_DATA'] = gdalDataPath
def Filter (inputRasterPath):
print('------------Filter------------')
print('Reading the image file..')
read = snappy.ProductIO.readProduct(inputRasterPath)
outputRasterPath = './Filter/Filter'+ pathlib.Path(inputRasterPath).suffix
print(read)
parameters = snappy.HashMap()
parameters.put('filter', 'Lee')
parameters.put('filterSizeX',3)
parameters.put('filterSizeY',3)
print('Filtering...')
speckle = snappy.GPF.createProduct('Speckle-Filter', parameters, read)
print('Filter successfully', speckle)
print('Writing the filtered image...')
snappy.ProductIO.writeProduct(speckle, outputRasterPath, 'GeoTIFF')
print('Done')
Best Answer
Thanks to user2856 i resolved this problem by adding
I have a little problem with
np.float32
: when i change data type to, for example,np.uint16
i have an error :So i decided to change the data type of a raster later, using
band_data.astype(src.dtypes[0])
The final code looks like this: