GeoSeries – How to Draw Buffer Circle Over a Map Using GeoSeries in Python

buffergeoseriespython

buf_df = geodata.copy()
buf_df['geometry'] = buf_df['geometry'].buffer(10)
fig, ax = plt.subplots(figsize=(10,10))
tx_shapefile.plot(ax=ax, facecolor='Grey', edgecolor='k',alpha=1,linewidth=1,cmap="binary")
buf_df.plot(ax=ax,color='red')
plt.title('Locations', fontsize=15,fontweight='bold')
plt.xlim(-98,-94)
plt.ylim(28,32)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
plt.show()

I want to plot the buf_df onto a shapefile plot. Basically draw buffer circles over my (lat,long) coordinates on the map. But it plots only a single circle on a normal plot

Best Answer

It looks like the coordinates of your geometries are in degrees, not in real-world distance units (like meters or feet). Therefore, the value you're using for your buffer is way too large and generates these huge circles that envelop your entire plotting area.

Try substituting your second line with this one:

buf_df['geometry'] = buf_df['geometry'].buffer(0.01)

This way, the buffer being generated is significantly smaller and will allow you to see most other things on the map.

If you need to draw a buffer of a specific size in the real world (for example, 10 meters, or 10 kilometers), you'll have to convert the GeoDataFrame's CRS to a projection-based one, apply the buffer, and then go back to the original CRS.

Related Question