在Basemap中绘制包装路径

时间:2016-05-25 13:48:32

标签: python plot maps matplotlib-basemap

我正在尝试绘制卫星地面轨道。我有一个度数的纬度和经度列表。经度值均为-180至+180度。我的第一个问题是使用$words = array("1", "2", "3", "4", "5", "6", "7", "8"); $rows = rand(1, 20); $cols = rand(1, 20); echo '<table>'."\n"; for($r = 1; $r <= $rows; ++$r) { echo '<tr>'."\n"; for($c = 1; $c <= $cols; ++$c) { // One word $td_text = $words[rand(0,(count($words)-1))]; // One to five words separated by a space // $td_text = substr(str_repeat($words[rand(0,(count($words)-1))].' ', rand(1, 5)), 0, -1); echo '<td>'.$td_text.'</td>'; } echo '</tr>'."\n"; } echo '</table>'; 关键字(顺便说一下,我通过latlon包在Julia中使用它,所以请原谅看起来很奇怪的语法):

PyCall.jl

Weird plot

这不是......应该是什么样子。我不确定问题是什么。但是,如果我先转换为地图坐标:

map = Basemap.Basemap(projection="mill",lon_0=0)
map[:drawcoastlines]()
map[:drawparallels](-90:30:90,labels=[1,0,0,0])
map[:drawmeridians](map[:lonmin]:60:map[:lonmax]+30,labels=[0,0,0,1])
map[:plot](lon,lat,color="red",latlon=true)

Better plot

这是更好的,除了之外的线经度从+180到-180。有什么建议使这看起来更好吗?

可以找到用于生成这些图的纬度,经度对(以度为单位)here

1 个答案:

答案 0 :(得分:7)

一开始我认为这可能与Basemap Basemap有关。但是,我认为你的问题不是由于import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap f = plt.figure(figsize(10,7.5)) m = Basemap(projection="mill", lon_0=0) m.drawcoastlines() m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0]) m.drawmeridians(np.arange(-180,181,60), labels=[0,0,0,1]) x,y = m(lon, lat) m.plot(x, y, color="red", latlon=False, marker='.', linestyle='None') ,它实际上正确地处理了经度包装,你可以看到你是否只使用标记来绘制卫星地面轨迹。

LineCollection

old issue

最终的解决方案是将您的地面轨迹分成多个轨道并使用import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap latlon_ar = np.array(latlon) threshold = 90 idx_wrap = np.nonzero(np.abs(np.diff(latlon_ar[:,1])) > threshold)[0]+1 lon_1 = lon[:idx_wrap] lat_1 = lat[:idx_wrap] lon_2 = lon[idx_wrap:] lat_2 = lat[idx_wrap:] f = plt.figure(figsize(10,7.5)) m = Basemap(projection="mill", lon_0=0) m.drawcoastlines() m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0]) m.drawmeridians(np.arange(-180,181,60), labels=[0,0,0,1]) x1, y1 = m(lon_1, lat_1) x2, y2 = m(lon_2, lat_2) m.plot(x1, y1, color="red", latlon=False) m.plot(x2, y2, color="blue", latlon=False) 绘制它们,同样如enter image description here所述。一种更简单的方法(如果你预计经度会出现一次不连续):

Basemap

here

修改 Basemap.plot中的enter image description here对问题的第一个示例中的行为负责,其中latlon直接使用纬度和经度值调用,将True标志设置为lons, lats = m.shiftdata(lon, lat) m.plot(lons, lats, color="blue", latlon=True, marker='.', linestyle='None') 。有confirmed bug,即在绘图之前手动移动输入坐标,如下面的代码所示。

String query = "update Table set someColumn ='T' where rownum<=?";
preparedStatement = dbConnection.prepareStatement(query);
for (i = num; i < limit; i += num) {
  preparedStatement.setInt(1, num);
  count = preparedStatement.addBatch();
}
preparedStatement.executeBatch();
dbConnection.commit();

solution