首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python城市shapefile

Python城市shapefile
EN

Stack Overflow用户
提问于 2013-07-21 14:56:04
回答 1查看 1.6K关注 0票数 1

我最近发现了一组很棒的免费GIS数据,包括圆锥体的所有城市。shapefile包含多层信息,如名称、人口、exct。我已经使用shapefile阅读器内置的底图绘制了城市的位置。然而,我似乎找不到一种方法来绘制城市的名称和位置。有没有一种方法可以使用底图来绘制城市名称及其位置?由于我是一名学生,所以我正在使用enthoughts发行版,因此某些附加模块可能无法获得。我已经链接了我的输出示例,并在文章底部链接到shapefile。如果任何人有任何想法,那将是很棒的!

谢谢,安德鲁

链接到美国国家海洋和大气局国家气象局http://www.nws.noaa.gov/geodata/catalog/national/html/cities.htm的shapefile

EN

回答 1

Stack Overflow用户

发布于 2013-07-21 15:15:22

文档中的示例中的以下内容将为您指明正确的方向:

代码语言:javascript
复制
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
# setup Lambert Conformal basemap.
m = Basemap(width=12000000,height=9000000,projection='lcc',
            resolution='c',lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
# draw a boundary around the map, fill the background.
# this background will end up being the ocean color, since
# the continents will be drawn on top.
m.drawmapboundary(fill_color='aqua')
# fill continents, set lake color same as ocean color.
m.fillcontinents(color='coral',lake_color='aqua')
# draw parallels and meridians.
# label parallels on right and top
# meridians on bottom and left
parallels = np.arange(0.,81,10.)
# labels = [left,right,top,bottom]
m.drawparallels(parallels,labels=[False,True,True,False])
meridians = np.arange(10.,351.,20.)
m.drawmeridians(meridians,labels=[True,False,False,True])
# plot blue dot on Boulder, colorado and label it as such.
lon, lat = -104.237, 40.125 # Location of Boulder
# convert to map projection coords.
# Note that lon,lat can be scalars, lists or numpy arrays.
xpt,ypt = m(lon,lat)
# convert back to lat/lon
lonpt, latpt = m(xpt,ypt,inverse=True)
m.plot(xpt,ypt,'bo')  # plot a blue dot there
# put some text next to the dot, offset a little bit
# (the offset is in map projection coordinates)
plt.text(xpt+100000,ypt+100000,'Boulder (%5.1fW,%3.1fN)' % (lonpt,latpt))
plt.show()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17769844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档