Home > other >  Cartopy problem in 3 d drawing
Cartopy problem in 3 d drawing

Time:09-21

How can take extra geographic base map

 import itertools 

The from mpl_toolkits. Mplot3d import Axes3D
The import matplotlib. Pyplot as PLT
The from matplotlib. Collections import LineCollection
The import numpy as np

The import cartopy. Feature
The from cartopy. MPL. Patch import geos_to_path
The import cartopy. CRS as CCRS
FIG=PLT. Figure (figsize=(1, 7), dpi=200)
Ax=Axes3D (FIG, xlim=[- 180, 180], ylim=[- 90, 90])
Ax. Set_zlim (bottom=0)


Target_projection=CCRS. PlateCarree ()

Feature=cartopy. Feature. NaturalEarthFeature (' physical ', 'coastline', '50 m)
Geoms=feature. Geometries' ()

Geoms=[target_projection project_geometry (the java.awt.geom feature. CRS)
For the java.awt.geom geoms] in

Paths=list (itertools. Chain. From_iterable (geos_to_path (the java.awt.geom) for the java.awt.geom in geoms))

# At this point, we start working around mpl3d 's slightly broken interfaces.
# So we produce a LineCollection rather than a PathCollection.
Segments=[]
For the path in paths:
Are=[vertex for vertex, _ in the path. The iter_segments ()]
Are=np. Asarray (are)
Segments. Append (are)

Lc=LineCollection (segments, color='black')
Ax. Add_collection3d (lc)
Ax. Set_xlabel (' X ')
Ax. Set_ylabel (' Y ')
Ax. Set_zlabel (' Height ')

PLT. The show ()
  • Related