Sunday 27 May 2018

python - Plotting GoeDataFrame on a raster


I have a bunch of polygons which I loaded from a shapefile into a fields GeoDataFrame:


   geometry                                           raster_val
0 POLYGON ((8.56799 47.80800, 8.56799 47.77200, ... 1.0
1 POLYGON ((6.73199 47.12400, 6.73199 47.08800, ... 1.0

I plot them using:


fields.plot(color='white', edgecolor='black')
matplotlib.pyplot.show()


I also have a raster layer (ndvi_layer) which is basically a numpy array which I plot using:


fig, ax = matplotlib.pyplot.subplots(figsize=(10, 10))
rasterio.plot.show(ndvi_layer, ax=ax, cmap='RdYlGn')
matplotlib.pyplot.show()

Is there any way to plot the polygons on top of the raster? What if the polygons don't have the same CRS as the raster?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...