You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将旋转坐标转换后的地理坐标角点绘制到底图中

Fixing Basemap Plotting for Converted Rotated Coordinates

Hey there! Let's get those converted geographic coordinates plotted on Basemap smoothly. From your data, it looks like you've got a closed polygon (since your lon/lat lists start and end at the same point)—that's perfect for outlining your study area. Here are the common pitfalls to avoid and a complete working code snippet:

Common Issues to Check

  • Projection Mismatch: If your Basemap uses a projection that doesn't align with your geographic coordinates, your plot might be skewed or invisible. Stick to a geographic projection like cyl (cylindrical equidistant) for starters, then switch to your desired projection once you confirm the points display correctly.
  • Coordinate Pairing: Make sure you're passing matching longitude and latitude pairs—mixing up indices will break the polygon shape.
  • Closed Polygon: You already have the last point matching the first, which is essential for drawing a closed boundary.

Working Code Example

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

# Your converted geographic coordinates
lons = [-13.7893, 39.6672, 82.6967, -54.64, -13.7893]
lats = [18.3262, 15.9548, 59.6559, 64.5671, 18.3262]

# Initialize Basemap with a cylindrical projection (easy for geographic coordinates)
fig, ax = plt.subplots(figsize=(10, 8))
m = Basemap(projection='cyl', llcrnrlat=-30, urcrnrlat=70,
            llcrnrlon=-60, urcrnrlon=90, resolution='l', ax=ax)

# Draw map features for context
m.drawcoastlines(linewidth=0.8)
m.drawcountries(linewidth=0.5)
m.drawparallels(range(-30, 71, 20), labels=[1,0,0,0])
m.drawmeridians(range(-60, 91, 30), labels=[0,0,0,1])

# Convert geographic coordinates to Basemap's projection coordinates
x, y = m(lons, lats)

# Plot the closed polygon
m.plot(x, y, color='red', linewidth=2, label='Study Area Boundary')
m.fill(x, y, color='pink', alpha=0.3)

# Add labels and legend
plt.title('Study Area on Basemap')
plt.legend()
plt.show()

Key Notes

  1. Projection Selection: The cyl projection is a safe default because it directly maps geographic lon/lat to plot coordinates. If you need a different projection (like ortho or merc), just replace the projection parameter and adjust the llcrnrlat, urcrnrlat, etc., to fit your region.
  2. Resolution: The resolution='l' uses low-resolution coastlines for faster plotting—switch to 'h' for high-res if you need more detail.
  3. Coordinate Conversion: Always use m(lons, lats) to convert your geographic coordinates to the Basemap's internal projection coordinates before plotting. This step is crucial for non-cylindrical projections.

If you're still seeing issues (like the polygon not showing up, or being in the wrong place), double-check that your converted geographic coordinates are correct. You can test by plotting individual points first with m.scatter(x, y) to verify each corner is in the right spot.

内容的提问来源于stack exchange,提问作者Vinod Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:11:31