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

关于terra包地理坐标(lon/lat)下面积计算的技术问询

Answer to terra Package Lon/Lat Area Calculation Questions

Let’s break down your questions about expanse() and cellSize() in the terra package clearly:

1. Are area calculations based on a sphere or ellipsoid?

By default, both functions use the WGS84 ellipsoid (the standard geographic reference for EPSG:4326 coordinates) for highly accurate area calculations. You can toggle this behavior with the ellipsoid parameter:

  • Keep ellipsoid = TRUE (the default) to stick with ellipsoid-based measurements.
  • Set ellipsoid = FALSE to switch to a simplified spherical calculation if needed.

Example code snippets:

# Calculate total raster area using ellipsoid (default)
total_expanse <- expanse(my_lonlat_raster)

# Generate a raster of cell areas using spherical geometry
cell_areas_sphere <- cellSize(my_lonlat_raster, ellipsoid = FALSE)

2. How does the algorithm compare to the fixed cell width (median width) method in the raster package?

The raster package’s area calculation (via area()) relies on estimating cell area using the median longitude of each cell to assign a fixed width. This can introduce noticeable errors, especially at high latitudes where the distortion of geographic coordinates makes cell shapes less uniform.

terra’s cellSize() and expanse() use a far more precise approach:

  • For every cell, they calculate the area of the polygon formed by the cell’s four corner coordinates.
  • This polygon area is computed using geodesic measurements tailored to your chosen ellipsoid (or sphere), which accounts for the actual curved shape of the cell on Earth’s surface.
  • expanse() then sums these individual, precise cell areas (either for the full raster or a subset) instead of relying on aggregated median width estimates.

This makes terra’s area calculations more accurate across all latitudes compared to the raster package’s method.


内容的提问来源于stack exchange,提问作者Jean-Luc Dupouey

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 12:47:42