Skip to content

fix: terra compat — replace raster::projectRaster in Fun.Soil_Geol#11

Merged
DankerMu merged 1 commit into
masterfrom
fix/terra-compat-soil-geol
Feb 13, 2026
Merged

fix: terra compat — replace raster::projectRaster in Fun.Soil_Geol#11
DankerMu merged 1 commit into
masterfrom
fix/terra-compat-soil-geol

Conversation

@DankerMu
Copy link
Copy Markdown
Owner

问题

Fun.Soil_Geol.R:62 使用 raster::projectRaster(r1, crs=xfg$crs.pcs),在 terra 1.8.x 环境下因 CRS slot 不兼容崩溃:

Error in .rawTransform(projfrom, projto, xy) :
  no slot of name "ptr" for this object of class "SpatVector"

此外原代码投影方向有误:将 PCS 栅格投影到 PCS(同 CRS),但写入的是 GCS 路径 (fg)。

修复

  • 替换为 terra::project(r1t, "EPSG:4326")
  • 修正投影方向:PCS → GCS (EPSG:4326)

验证(SHUD 服务器环境)

  • R 4.3.1 + terra 1.8.86 + raster 3.6-26
  • AutoSHUD Step1-3 baseline profile 全部通过
  • qhh.sp.riv MD5 可复现 (78763f08)
  • slope vs DEM 真值 cor=1.0,端点偏差 <0.5m

raster::projectRaster crashes with terra 1.8.x due to CRS slot
incompatibility (.rawTransform expects old-style CRS).

Also fixes projection direction: original code projected PCS→PCS
(same CRS, no-op), but the GCS output file needs PCS→EPSG:4326.

Tested: SHUD server env, AutoSHUD Step1-3 baseline pass.
@DankerMu
Copy link
Copy Markdown
Owner Author

Review

单文件修复,改动明确:

  1. raster::projectRasterterra::project 解决 terra 1.8.x CRS 兼容性崩溃
  2. 修正投影方向 PCS→GCS(原代码 PCS→PCS 是 no-op 且写入 GCS 路径)

SHUD 服务器环境验证 Step1-3 baseline 全部通过,sp.riv MD5 可复现。

@DankerMu DankerMu merged commit 09e8e2e into master Feb 13, 2026
3 checks passed
@DankerMu DankerMu deleted the fix/terra-compat-soil-geol branch February 13, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant