我正在努力將人口數量從一個行政級別重新匯總到另一個行政級別。一個特定的行不斷回傳錯誤“替換有 4 行,資料有 2”。
我曾嘗試驗證幾何形狀,但沒有奏效。距離為 0 的緩沖區也沒有。
我正在準備使用 dput() 發布此問題的虛擬資料。將 sf 層的 dput() 保存到文本檔案后,命令列在重新分配變數后作業。這僅在使用保存在文本檔案中的 dput 輸出時有效,但如果我直接使用
st_interpolate_aw(dput(geography1),dput(geography2), extensive = TRUE).
這將回傳相同的錯誤。
是否有任何已知的可能發生錯誤的原因,以及如何將dput() 輸出保存到 .txt 檔案中可能會消除錯誤?
注意 - 除了 dput() 之外,還有其他方法可以共享功能嗎?其中一層中的大量頂點超過了問題的字符限制
編輯我想我設法匯出帶有錯誤的geojson,以防您有興趣檢查它:https ://drive.google.com/file/d/1wF6AB1oHVEkcuI4iRAloLO56DL_8EZBr/view?usp=sharing
uj5u.com熱心網友回復:
我認為問題在于兩個物件相交的性質;似乎交叉點產生了兩個多邊形型別的物件(完全可以)和兩個線型物件;根據定義,它們具有零區域,這會破壞插值程序。
你有兩個選擇:
- 稍微調整一下后面的代碼
sf::st_interpolate_aw()以強制過濾器在幕后處理多邊形幾何 - 將處理引擎從閃亮的新GEOS 切換
{s2}到可靠的舊 GEOS
我建議做后者,如下面的代碼所示,但提出拉取請求{sf}將是牛仔的事情:)
library(sf)
library(dplyr)
big <- st_read("SA1_suburb_1221.geojson")
small <- st_read("suburb_1221.geojson")
st_intersection(st_geometry(big), st_geometry(small))
# Geometry set for 4 features
# Geometry type: GEOMETRY
# Dimension: XY
# Bounding box: xmin: 142.8129 ymin: -36.75028 xmax: 142.9655 ymax: -36.63092
# Geodetic CRS: WGS 84
# LINESTRING (142.9648 -36.75015, 142.9648 -36.75...
# POLYGON ((142.8673 -36.63148, 142.8371 -36.6315...
# MULTILINESTRING ((142.9648 -36.74569, 142.9648 ...
# MULTIPOLYGON (((142.9515 -36.74478, 142.9515 -3...
sf_use_s2(F)
st_intersection(st_geometry(big), st_geometry(small))
# although coordinates are longitude/latitude, st_intersection assumes that they are planar
# Geometry set for 2 features
# Geometry type: GEOMETRY
# Dimension: XY
# Bounding box: xmin: 142.8129 ymin: -36.75028 xmax: 142.9655 ymax: -36.63092
# Geodetic CRS: WGS 84
# POLYGON ((142.9648 -36.75015, 142.9645 -36.7499...
# GEOMETRYCOLLECTION (POLYGON ((142.9504 -36.7467...
result <- st_interpolate_aw(big["below_poverty"],
st_geometry(small),
extensive = F)
result
# // a perfectly reasoneable result
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/531343.html
上一篇:對native-lands.ca的RhttrPOST請求
下一篇:在ggplot中處理柵格資料
