'ploting a raster image in matplotlib
im trying to display a raster image in matplotlib the image looks like this
i can do this with rasterio
import rasterio as rs
ds =rs.open('image')
show(ds)
what i want to do is change the cmap to a differnt color spectrum to build a data set for image calssifcation. so like this
show(ds, cmap = "Spectral")
the problem is I then have to save this large image and then go to that new image location and extract the data. this just take to long for the dataset i have. so I want to do with matplotilp so I can set the cmap with out having to save the image or display the image. but when i try to load the image into matplotlib I get an image back like this.
array = ds.read(1)
fig = plt.imshow(array)
plt.show()
i receive this image back
the profile of the raster = {'driver': 'GTiff', 'dtype': 'float32', 'nodata': -32768.0, 'width': 29864, 'height': 22223, 'count': 1, 'crs': CRS.from_epsg(32633), 'transform': Affine(10.0, 0.0, 113068.92839579273, 0.0, -10.0, 5004940.946787545), 'tiled': False, 'interleave': 'band'}
i think the problem might have to do with 'dtype': 'float32', 'nodata': -32768.0
what i tried doing was setting the vmax and vmin like this fig = plt.imshow(array,vmin =(array.min()), vmax = (array.max()) this still didn't work. would really appreciate some help with being able to prosses this image in matplotlib or a way to setting the cmap to a different color setting. so I can exstat the pixel from areas of interest to then build an image classification model from these images.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|



