从shapefile获取的经度和纬度中获取数据

时间:2019-05-22 19:32:46

标签: python-3.x matplotlib-basemap

我有一个带有纬度和经度的模型输出,但是我只想获取来自我在Santa Maria市的shapefile的数据。 我不明白您是如何从我的城市shapefile中获取纬度和经度数据的。 会吗?

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

dataset = Dataset('./wrfout_1_9_d03_2009-09-07_00:00:00')

nc = dataset.variables['HAILNC'][:]
lat = dataset.variables['XLAT'][:]
lon = dataset.variables['XLONG'][:]
time_var = dataset.variables['XTIME']
nc_units = dataset.variables['HAILNC'].units

plt.figure()
m = Basemap(projection='cyl', resolution='h',
            lon_0=-10,
            llcrnrlat=-32, urcrnrlat = -27,
            llcrnrlon=-57, urcrnrlon = -50)
m.drawcoastlines(linewidth=0.5)

m.readshapefile('./municipiors4326', 'comarques',drawbounds = False)

for info, shape in zip(m.comarques_info, m.comarques):
    if info['MUNICIPIO'] == 'Santa Maria':
         x, y = zip(*shape)
         print(x,y)
m.plot(x, y, marker=None,color='k',linewidth=1)
m.pcolormesh(lon[int(i),:,:], lat[int(i),:,:], nc[int(i),:,:],latlon=True)#, cmap=cmap, norm=norm)
plt.title('my figure')

图中的数字:https://imgur.com/UA9bPWi

在图形的中心是我的形状。

我的shapefile的纬度和经度是:

但是,我只希望从shapefile中获取经纬度数据。

我只想在我的shapefile中获取数据,但是为此,我需要从WRF(模板)中提取数据,该模板中有很多经纬度。如下例所示。但是,我只想要来自shapefile的经纬度数据。

图:https://i.stack.imgur.com/W7L7X.png

谢谢!

0 个答案:

没有答案
相关问题