What do I need to do to visualize Sentinel-1 data with rasterio?


earthdata@...
 

I'm a first time user. I downloaded a Sentinel-1 granule. I'm now trying to visualize it via the following script:
import rasterio
from rasterio.plot import show
path = '.../x.SAFE/measurement/y-001.tiff'
src = rasterio.open(path)
show(src)
However this gives me the following error:
TypeError: Image data of dtype complex128 cannot be converted to float
What else do I need to do?


Yann-Sebastien Tremblay-Johnston
 

Looks like your data is Single Look Complex (SLC), you'll need to convert it to float. You can do this yourself with numpy, or with https://gdal.org/drivers/raster/derived.html GDAL (which rasterio uses under the hood) will compute the intensity for you. 

e.g.

src = rasterio.open('DERIVED_SUBDATASET:INTENSITY:../x.SAFE/measurement/y-001.tif')

Sebastien
   

On Wed, May 26, 2021 at 12:38 PM <earthdata@...> wrote:
I'm a first time user. I downloaded a Sentinel-1 granule. I'm now trying to visualize it via the following script:
import rasterio
from rasterio.plot import show
path = '.../x.SAFE/measurement/y-001.tiff'
src = rasterio.open(path)
show(src)
However this gives me the following error:
TypeError: Image data of dtype complex128 cannot be converted to float
What else do I need to do?


Sean Gillies
 

Thanks, Sebastian!

rasterio.plot.show cannot deal with complex arrays. It looks like a library called mpmath can, might be worth looking in https://mpmath.org/gallery/.


On Wed, May 26, 2021 at 1:46 PM Yann-Sebastien Tremblay-Johnston <yanns.tremblay@...> wrote:
Looks like your data is Single Look Complex (SLC), you'll need to convert it to float. You can do this yourself with numpy, or with https://gdal.org/drivers/raster/derived.html GDAL (which rasterio uses under the hood) will compute the intensity for you. 

e.g.

src = rasterio.open('DERIVED_SUBDATASET:INTENSITY:../x.SAFE/measurement/y-001.tif')

Sebastien
   

On Wed, May 26, 2021 at 12:38 PM <earthdata@...> wrote:
I'm a first time user. I downloaded a Sentinel-1 granule. I'm now trying to visualize it via the following script:
import rasterio
from rasterio.plot import show
path = '.../x.SAFE/measurement/y-001.tiff'
src = rasterio.open(path)
show(src)
However this gives me the following error:
TypeError: Image data of dtype complex128 cannot be converted to float
What else do I need to do?

._,

--
Sean Gillies