How to plot Shapefile in Python | Part-02

preview_player
Показать описание
In this video a detailed explain about how a shapefile can be plotted in python is discussed. Along with that it is also discussed how a base map can be added to the background of the plotted shapefile along with the details like north arrow, scalebar, legend and also make the shapefile transparent.

Code used:
import geopandas as gpd
import contextily as ctx

def numft(x,pos):
s =f'{x/1000:,.0f}'
return s

shape_file = "path to shapefile"

z_pal =[0,5910,6310,7740,12170]
pal_rgb = ['aqua','purple','brown', 'red']
cmap2,norm =from_levels_and_colors(z_pal,pal_rgb,extend= 'neither')

# Create a Patch object with the desired properties
catalunya_line = mlines.Line2D([], [], color='black', label='Catalunya provinces')

# catalunya_patch = mpatches.Patch(color='black', label='Catalunya provinces')

formatter = tik.FuncFormatter(numft)
# Add the north arrow
x, y, arrow_length = 0.95, 1, 0.09
arrowprops=dict(facecolor='black', width=5, headwidth=15),
ha='center', va='center', fontsize=26,
scalebar = ScaleBar(0.001, units='km', location='lower center')

divider = make_axes_locatable(ax)

Рекомендации по теме
Комментарии
Автор

Thank u. Make more video like this plz

thelongnguyen
join shbcf.ru