[Python] Basemap入坑手册 - 地图投影示例
程序员文章站
2022-06-15 17:23:35
...
Basemap入坑手册 - 地图投影示例
文章目录
- Basemap入坑手册 - 地图投影示例
- cyl - Cylindrical Equidistant
- merc - Mercator
- tmerc - Transverse Mercator
- omerc - Oblique Mercator
- mill - Miller Cylindrical
- gall - Gall Stereographic
- cea - Cylindrical Equal-Area
- lcc - Lambert Conformal
- laea - Lambert Azimuthal Equal Area
- nplaea - North-Polar Lambert
- splaea - South-Polar Lambert
- eqdc - Equidistant Conic
本文是Basemap入坑手册的一个附录,主要对Basemap中各种地图投影方式提供一个示例。
cyl - Cylindrical Equidistant
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'cyl')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
# 送上标题
plt.title("Cylindrical Equidistant Projection")
plt.show()
结果:
merc - Mercator
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'merc', llcrnrlat = -80, urcrnrlat = 80, llcrnrlon = -180, urcrnrlon = 180, lat_ts = 20, resolution = 'c')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
# 送上标题
plt.title("Mercator Projection")
plt.show()
结果:
tmerc - Transverse Mercator
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'tmerc', llcrnrlat = 49.5, urcrnrlat = 59.5, llcrnrlon = -10.5, urcrnrlon = 3.5, lon_0 = -4.36, lat_0 = 54.7, resolution = 'i')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-40,61.,2.))
m.drawmeridians(np.arange(-20.,21.,2.))
# 送上标题
plt.title("Transverse Mercator Projection")
plt.show()
结果:
omerc - Oblique Mercator
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'omerc', height = 16700000, width = 12000000, area_thresh = 1000., lon_0 = -100, lat_0 = 15, lon_1 = -50, lat_1 = -55, lon_2 = -120, lat_2 = 65, resolution = 'l')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(180.,181.,20.))
# 送上标题
plt.title("Oblique Mercator Projection")
plt.show()
结果:
mill - Miller Cylindrical
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'mill', llcrnrlat = -90, urcrnrlat = 90, llcrnrlon = -180, urcrnrlon = 180, resolution = 'c')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
# 送上标题
plt.title("Miller Cylindrical Projection")
plt.show()
结果:
gall - Gall Stereographic
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'gall', llcrnrlat = -90, urcrnrlat = 90, llcrnrlon = -180, urcrnrlon = 180, resolution = 'c')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
# 送上标题
plt.title("Gall Stereographic Projection")
plt.show()
结果:
cea - Cylindrical Equal-Area
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'cea', llcrnrlat = -90, urcrnrlat = 90, llcrnrlon = -180, urcrnrlon = 180, resolution = 'c')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
# 送上标题
plt.title("Cylindrical Equal-Area Projection")
plt.show()
结果:
lcc - Lambert Conformal
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'lcc', lat_0 = 50, lon_0 = -107., lat_1 = 45., lat_2 = 55, width = 12000000, height = 9000000, rsphere = (6378137.00, 6356752.3142), resolution = 'l')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
# 送上标题
plt.title("Lambert Conformal Projection")
plt.show()
结果:
laea - Lambert Azimuthal Equal Area
代码:
# 导入包
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# 投影方式选择
m = Basemap(projection = 'laea', lat_0 = 50, lon_0 = -107., lat_ts = 50, width = 12000000, height = 8000000, resolution = 'l')
# 画海岸线
m.drawcoastlines()
# 上色
m.fillcontinents(color = 'coral', lake_color = 'aqua')
m.drawmapboundary(fill_color = 'aqua')
# 画经纬度线
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
# 送上标题
plt.title("Lambert Azimuthal Equal Area Projection")
plt.show()
结果:
nplaea - North-Polar Lambert
代码:
结果:
splaea - South-Polar Lambert
代码:
结果:
eqdc - Equidistant Conic
代码:
结果:
- Azimuthal Equidistant
代码:
结果:
- North-Polar Azimuthal
代码:
结果:
- South-Polar Azimuthal
代码:
结果:
- Albers Equal
代码:
结果:
- Stereographic
代码:
结果:
- ??
代码:
结果:
上一篇: PHP正则匹配字符串中的中文