Wednesday 11 November 2020

Display spectrum of region of interest with Rasterio and Geopandas

I believe is very simle question but for some reason I really struggle with finding the way to do that.

I have plot a satellite image that has 13 bands and shapefile that located on top of it, using Rasterio and Geopandas as following:

shapefile = gpd.read_file('ROI.shp')


# plots both elements
fig, ax = plt.subplots(figsize=(20,10))

ax = rasterio.plot.show(src.read([4,3,2]),transform=src.transform,title='Image- bands 4,3,2 ',vmin=0,vmax=30000,with_bounds=True, ax=ax)
shapefile.plot(ax=ax)

enter image description here

and this is the table of the shapefile:


id  ROI geometry
0   4   Urban   POLYGON ((34.45501 31.53714, 34.48213 31.52649...
1   2   Sea POLYGON ((34.41933 31.54509, 34.40629 31.50923...
2   3   Agriculture MULTIPOLYGON (((34.49357 31.36081, 34.49463 31

My question is, is there any way I can plot the spectum of the region of interest I have created? e.g the sea, the agriculture and the urban area? I want to get in the end line chart that has spectrum. The only way I could think about is to rasterize the shapefile and then to pandas and to plot it, I believe ther emsut be better way to get the same results with Rasterio.

my desired output is line chart when X axis is the bands of the image (or the wavelength) and the Y axis is the value on that band.



from Display spectrum of region of interest with Rasterio and Geopandas

No comments:

Post a Comment