Reputation: 197
I am trying to add a shapefile over a satellite image using cartogee in geemap. I got successful in plotting the satellite imagery but got error while adding the shapefile. The script I used is
# Set range of map, stipulate zoom level
ax.set_extent([90.1705247321613115,26.0299380202123096 , 90.1918066009087056,26.0460906028715726], crs=ccrs.Geodetic())
fig = plt.figure(figsize=(10,7))
vis = {
"bands":["VV","VV","VV"],
"min":-25,
"max":0,
#"palette":['aqua', 'black']
}
# use cartoee to get a map
ax = cartoee.get_map(Sentinel_1,vis_params=vis,region=zoom_region)
# add a colorbar to the map using the visualization params we passed to the map
cartoee.add_colorbar(ax, vis, loc="right",label="Backscatter",orientation="vertical")
# add gridlines to the map at a specified interval
cartoee.add_gridlines(ax,interval=[0.005,0.005],linestyle=":")
filename = r'E:/Final shapefiles.shp'
shape_feature = ShapelyFeature(Reader(filename).geometries(), ccrs.epsg(32646),
linewidth = 1, facecolor = (1, 1, 1, 0),
edgecolor = (0.5, 0.5, 0.5, 1))
ax=add_feature(shape_feature)
plt.show()
And the error is
NameError Traceback (most recent call last)
<ipython-input-125-7e5d43a82605> in <module>
23 linewidth = 1, facecolor = (1, 1, 1, 0),
24 edgecolor = (0.5, 0.5, 0.5, 1))
---> 25 ax=add_feature(shape_feature)
26 plt.show()
NameError: name 'add_feature' is not defined
But I get the image output as
Output is without the shapefile due to error
Upvotes: 1
Views: 217