计算2个Geo Shapefile重叠的位置

时间:2018-07-11 20:15:02

标签: python polygon shapefile

我有2个shapefile,其中一个是美国县,另一个是影响某些县的风暴模式。我正在尝试查看哪些县受到了该特定风暴shapefile的影响。即告诉我哪个县被风暴shapefile覆盖了。我正在用matplotlib底图绘制shapefile。

fig, ax = plt.subplots(figsize=(20,20))

ll_lon = -96.7676
ur_lon = -88.461978
ll_lat = 43.319692
ur_lat = 49.233720

centerlon = float(ll_lon + ur_lon) / 2.0
centerlat = float(ll_lat + ur_lat) / 2.0

m = Basemap(resolution = 'i',
            llcrnrlon = ll_lon,
            urcrnrlon = ur_lon,
            llcrnrlat = ll_lat,
            urcrnrlat = ur_lat,
            lat_0 = centerlat, 
            lon_0 = centerlon, 
            projection = 'lcc')

cnty_shpfile = m.readshapefile('/home/nick/MapData/cb_2016_us_county_500k', 'county', drawbounds=True,
                               color='gray')

hail_shpfile = m.readshapefile('/home/nick/MyProjects/SWATH/swath', 'hail', drawbounds=True, color='red')

patches = []
for info, shape in zip(m.hail_info, m.hail):
    if info['name'] == '1.50 inch hail\x00':   
        patches.append(Polygon(np.array(shape), True))

ax.add_collection(PatchCollection(patches, facecolor='darkgreen', linewidths=1.))

plt.show()

0 个答案:

没有答案