mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-20 12:50:47 +08:00
5.2 KiB
5.2 KiB
In [ ]:
import geopandas
import geoplot
world = geopandas.read_file(
geopandas.datasets.get_path('naturalearth_lowres')
)
boroughs = geopandas.read_file(
geoplot.datasets.get_path('nyc_boroughs')
)
collisions = geopandas.read_file(
geoplot.datasets.get_path('nyc_injurious_collisions')
)In [ ]:
geoplot.polyplot(world, figsize=(8, 4))In [ ]:
# use the Orthographic map projection (e.g. a world globe)
ax = geoplot.polyplot(
world, projection=geoplot.crs.Orthographic(), figsize=(8, 4)
)
ax.outline_patch.set_visible(True)In [ ]:
import mapclassify
gpd_per_person = world['gdp_md_est'] / world['pop_est']
scheme = mapclassify.Quantiles(gpd_per_person, k=5)
# Note: this code sample requires geoplot>=0.4.0.
geoplot.choropleth(
world, hue=gpd_per_person, scheme=scheme,
cmap='Greens', figsize=(8, 4)
)In [ ]:
africa = world.query('continent == "Africa"')
ax = geoplot.cartogram(
africa, scale='pop_est', limits=(0.2, 1),
edgecolor='None', figsize=(7, 8)
)
geoplot.polyplot(africa, edgecolor='gray', ax=ax)In [ ]:
ax = geoplot.kdeplot(
collisions.head(1000), clip=boroughs.geometry,
shade=True, cmap='Reds',
projection=geoplot.crs.AlbersEqualArea())
geoplot.polyplot(boroughs, ax=ax, zorder=1)