Skip to content

overlay shapefile on raster based on raster extent #754

@AminFazlKazemi

Description

@AminFazlKazemi

Hi
I want to plot a global covering shapefile over a raster whose extent is not global. In fact I want just zoom to raster extent,
How can I do that
I used

data = rioxarray.open_rasterio(raster_address, masked=True)

Creating the plot extent object

data_plot_extent = plotting_extent(data[0],data.rio.transform())

data.xshape.overlay(shapefile_address,encoding='latin1')

boundary = (gpd.read_file(shp_address)).to_crs(es.crs_check(address))
fig,ax = plt.subplots()

da.sel(band=1).plot.contourf()
boundary.boundary.plot(ax=ax,extent=data_plot_extent,color="black")

but it didn't work
I would be very thankfull if you help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions