使用底图获取城市地图的最佳方法? - python

我正在尝试使用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获取旧金山的地图呢?

参考方案

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

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

Matplotlib'粗体'字体 - python

跟随this example:import numpy as np import matplotlib.pyplot as plt fig = plt.figure() for i, label in enumerate(('A', 'B', 'C', 'D')): ax = f…

matplotlib:使加号变粗 - python

在Matplotlib中,我想绘制一个粗体加号(或一个十字),但是marker set中提供的那个太 thin 。即使增加它的大小,它也不会变厚。对于example:绘制红色加号的lines of code是:# Draw median marker. if plot_opts.get('bean_show_median', True):…

在返回'Response'(Python)中传递多个参数 - python

我在Angular工作,正在使用Http请求和响应。是否可以在“响应”中发送多个参数。角度文件:this.http.get("api/agent/applicationaware").subscribe((data:any)... python文件:def get(request): ... return Response(seriali…

Python exchangelib在子文件夹中读取邮件 - python

我想从Outlook邮箱的子文件夹中读取邮件。Inbox ├──myfolder 我可以使用account.inbox.all()阅读收件箱,但我想阅读myfolder中的邮件我尝试了此页面folder部分中的内容,但无法正确完成https://pypi.python.org/pypi/exchangelib/ 参考方案 您需要首先掌握Folder的myfo…

python JSON对象必须是str,bytes或bytearray,而不是'dict - python

在Python 3中,要加载以前保存的json,如下所示:json.dumps(dictionary)输出是这样的{"('Hello',)": 6, "('Hi',)": 5}当我使用json.loads({"('Hello',)": 6,…