为什么一些气象站坐标在尼日利亚边界之外?
Why are some of the weather station coordinates out of the Nigerian boundary?
以下代码行已用于绘制尼日利亚气象站的点(坐标),不幸的是,一些气象站位于该国边界之外。我确认气象站的纬度和经度准确无误,并进行了双重检查。对此分支的任何 suggestion/solution 将不胜感激。谢谢。
...
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as feature
import cartopy.io.shapereader as shapereader
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import pandas as pd
df = pd.read_csv("met_ngstation.csv")
countries = shapereader.natural_earth(resolution='10m',
category='cultural',
name='admin_0_countries')
# Find the Nigeria boundary polygon.
for country in shapereader.Reader(countries).records():
if country.attributes['SU_A3'] == 'NGA':
nigeria = country.geometry
break
else:
raise ValueError('Unable to find the NGA boundary.')
plt.figure(figsize=(20, 10))
ax_map = plt.axes(projection=ccrs.PlateCarree())
ax_map.set_extent([-1, 19, -1, 17], ccrs.PlateCarree())
#ax_map.coastlines()
ax_map.add_feature(feature.COASTLINE, linewidth=.5)
ax_map.add_geometries([nigeria], ccrs.PlateCarree(),
edgecolor='0.8',
facecolor='none')
grid_lines = ax_map.gridlines(draw_labels=True)
grid_lines.top_labels = False
grid_lines.right_labels = False
lon_formatter = LongitudeFormatter(zero_direction_label=True)
lat_formatter = LatitudeFormatter()
ax_map.xaxis.set_major_formatter(lon_formatter)
ax_map.yaxis.set_major_formatter(lat_formatter)
plt.scatter(df['LONG'],df['LAT'],
color='red', marker='.',
transform=ccrs.PlateCarree())
#plt.savefig('coastlines_ng.pdf')
#plt.savefig('coastlines_ng.png')
plt.show()
'''
Link 映射:
https://drive.google.com/file/d/1cNnylUOmi-Dg6ioZE0tQj7xCHRdMPIh8/view?usp=sharing
正如@JodyKlymak 所建议的,这是输入数据的问题,而不是 cartopy。
您可以使用 Google 地图
等在线地图服务进行检查
从这张图片中,您可以看到链接数据集中的“Eket”站,lon=7.95,lat=4.4,位于 Kwa Ibo 近海 10 公里处。这是典型的气象浮标
经常检查你的输入数据!
以下代码行已用于绘制尼日利亚气象站的点(坐标),不幸的是,一些气象站位于该国边界之外。我确认气象站的纬度和经度准确无误,并进行了双重检查。对此分支的任何 suggestion/solution 将不胜感激。谢谢。
...
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as feature
import cartopy.io.shapereader as shapereader
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
import pandas as pd
df = pd.read_csv("met_ngstation.csv")
countries = shapereader.natural_earth(resolution='10m',
category='cultural',
name='admin_0_countries')
# Find the Nigeria boundary polygon.
for country in shapereader.Reader(countries).records():
if country.attributes['SU_A3'] == 'NGA':
nigeria = country.geometry
break
else:
raise ValueError('Unable to find the NGA boundary.')
plt.figure(figsize=(20, 10))
ax_map = plt.axes(projection=ccrs.PlateCarree())
ax_map.set_extent([-1, 19, -1, 17], ccrs.PlateCarree())
#ax_map.coastlines()
ax_map.add_feature(feature.COASTLINE, linewidth=.5)
ax_map.add_geometries([nigeria], ccrs.PlateCarree(),
edgecolor='0.8',
facecolor='none')
grid_lines = ax_map.gridlines(draw_labels=True)
grid_lines.top_labels = False
grid_lines.right_labels = False
lon_formatter = LongitudeFormatter(zero_direction_label=True)
lat_formatter = LatitudeFormatter()
ax_map.xaxis.set_major_formatter(lon_formatter)
ax_map.yaxis.set_major_formatter(lat_formatter)
plt.scatter(df['LONG'],df['LAT'],
color='red', marker='.',
transform=ccrs.PlateCarree())
#plt.savefig('coastlines_ng.pdf')
#plt.savefig('coastlines_ng.png')
plt.show()
'''
Link 映射: https://drive.google.com/file/d/1cNnylUOmi-Dg6ioZE0tQj7xCHRdMPIh8/view?usp=sharing
正如@JodyKlymak 所建议的,这是输入数据的问题,而不是 cartopy。
您可以使用 Google 地图
等在线地图服务进行检查从这张图片中,您可以看到链接数据集中的“Eket”站,lon=7.95,lat=4.4,位于 Kwa Ibo 近海 10 公里处。这是典型的气象浮标
经常检查你的输入数据!