
import geopandas as gpd
import matplotlib.pyplot as plt
# Load the shapefile
shapefile_path = "/home/student/tsjohnson/NA_CEC_Eco_Level2.shx"
level2 = gpd.read_file(shapefile_path)
# Create the plot
ax = level2.plot(edgecolor='black', figsize=(10, 8))
# Set axis limits
ax.set_xlim([-2.25E6,-1E6])
ax.set_ylim([-1E6, 0.6E6])
# Show the plot
plt.show()
Я попробовал это, изображение растянулось и ничего не добавилось.
import geopandas as gpd
import matplotlib.pyplot as plt
# Load the shapefile
shapefile_path = "/home/student/tsjohnson/NA_CEC_Eco_Level2.shx"
level2 = gpd.read_file(shapefile_path)
# Create the plot with white background
fig, ax = plt.subplots(figsize=(10, 8))
level2.plot(ax=ax, edgecolor='black')
# Set axis limits
ax.set_xlim([-2.25E6, -1E6])
ax.set_ylim([-1E6, 0.5E6])
ax.set_facecolor('white')
us_states = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
states = us_states[us_states['continent'] == 'North America'] # Filter for North American states
states.boundary.plot(ax=ax, linewidth=1, color='black')
plt.show()
Подробнее здесь: https://stackoverflow.com/questions/792 ... or-cartopy