【问题标题】:Best way to get a map of a city using Basemap?使用 Basemap 获取城市地图的最佳方式?
【发布时间】:2015-09-24 01:54:30
【问题描述】:

我正在尝试使用 Basemap 在 python 中显示一个城市的地图,例如旧金山。我尝试了以下方法:

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# lat_ts is the latitude of true scale.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='merc',llcrnrlat=37.79,urcrnrlat=37.81,\
        llcrnrlon=-122.42,urcrnrlon=-122.4,lat_ts=20,resolution='c')
m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
m.drawmapboundary(fill_color='aqua')
plt.title("Mercator Projection")
plt.show()

但是,这不起作用,只会在地图应有的位置显示蓝色。那么如何使用 python 获取旧金山的地图呢?

【问题讨论】:

    标签: python google-maps matplotlib gis geo


    【解决方案1】:

    您的坐标一定是错误的:它显示为蓝色,因为您正在某处放大海洋。

    此外,此代码只会绘制海岸线as explained in the documentation。要获取城市地图,您实际上需要使用可用的后端之一加载相应的数据。例如,您可以从ArcGIS 等API 服务中查询数据,with the corresponding method

    【讨论】:

      猜你喜欢
      • 2014-02-27
      • 2017-03-27
      • 1970-01-01
      • 2011-05-29
      • 1970-01-01
      • 2017-10-25
      • 2010-11-09
      • 1970-01-01
      • 2011-08-12
      相关资源
      最近更新 更多