Этот код покажет вам все возможные проекции (за исключением transverse mercator
, который не работает с данными этого примера, но когда я тестировал другие данные, он работал).
Картографические карты будут сохранены в папку ./projections/
.
Источник списка проекций: https://plotly.com/python/map-configuration/#map-projections
import plotly.express as px
from pathlib import Path
df = px.data.election()
geojson = px.data.election_geojson()
fig = px.choropleth(df, geojson=geojson, color="Bergeron",
locations="district", featureidkey="properties.district")
fig.update_layout(margin={"r":10,"t":50,"l":10,"b":10})
fig.update_geos(fitbounds='locations', resolution=50,scope='north america')
projections = ['equirectangular', 'mercator', 'orthographic', 'natural earth',
'kavrayskiy7', 'miller', 'robinson', 'eckert4', 'azimuthal equal area',
'azimuthal equidistant', 'conic equal area', 'conic conformal',
'conic equidistant', 'gnomonic', 'stereographic', 'mollweide', 'hammer',
'transverse mercator', 'albers usa', 'winkel tripel', 'aitoff', 'sinusoidal']
Path('./projections/').mkdir(parents=True, exist_ok=True)
for p in projections:
fig.update_geos(projection_type=p)
fig.update_layout(title=p)
path=f'./projections/{p}.png'
fig.write_image(file=path,width=960,height=540,scale=2)
18.06.2021