- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须沿着一个曲折的特征来克里格值。因此,我必须将正常的笛卡尔坐标 (x,y) 转换为曲线坐标系 (s,n)。曲线坐标允许我进行克里格法,在克里格法之后,我可以将坐标反转为笛卡尔 x,y 以便表示原始几何。对于可重现的示例,将使用 meuse
数据集和 sp
包裹。
data(meuse)
meuse$s<-meuse$x # Assuming that s is the curvilinear transformed coordinate from the orginal x cartessian coordinate
meuse$n<-meuse$y # Assuming that n is the curvilinear transformed coordinate from the orginal y cartessian coordinate
coordinates(meuse) <- ~s+n # Using the curvilinear coordinates to do the krigging
proj4string(meuse) <- nl.rd # projection not defined, so just used a random example
## load grid:
data(meuse.grid)
meuse.grid$XX<-meuse.grid$x+105 # Fake transformation value to give original X
meuse.grid$YY<-meuse.grid$y-77 # Fake transformation value to give original Y
meuse.grid$s <-meuse.grid$x # Assuming that s is the curvilinear transformed coordinate from the orginal x cartessian coordinate
meuse.grid$n <-meuse.grid$y # Assuming that n is the curvilinear transformed coordinate from the orginal y cartessian coordinate
coordinates(meuse.grid) <- ~s+n
gridded(meuse.grid) <- TRUE
## A simple inverse distance krig
zinc.id <- krige(zinc~1, meuse, meuse.grid)
meuse.grid$zinc.id <- zinc.id$var1.pred
str(meuse.grid)
meuse.grid
中但是对于 s,n 坐标,我想使用 x,y 笛卡尔坐标来查看最终结果(假设将 s,n 转换为 x,y 完全等于 x,y 到 s,n)。我可以吗,如果可以,我如何才能将网格中的 (s,n) 值替换为 (XX,YY),因为
meuse.grid
已经是一个 SpatialPointsDataFrame。
最佳答案
访问 SpatialPointsDataFrame
中的原始数字,只需使用 as.data.frame
将其转换为 data.frame
:
> head(as.data.frame(meuse.grid))
x y part.a part.b dist soil ffreq XX YY zinc.id
1 181180 333740 1 0 0.0000000 1 1 181285 333663 633.6864
2 181140 333700 1 0 0.0000000 1 1 181245 333623 712.5450
3 181180 333700 1 0 0.0122243 1 1 181285 333623 654.1617
4 181220 333700 1 0 0.0434678 1 1 181325 333623 604.4422
5 181100 333660 1 0 0.0000000 1 1 181205 333583 857.2558
6 181140 333660 1 0 0.0122243 1 1 181245 333583 755.5061
s n
1 181180 333740
2 181140 333700
3 181180 333700
4 181220 333700
5 181100 333660
6 181140 333660
coordinates
再次将对象改回
SpatialPointDataFrame
用于绘图。
关于r - 更改已采用 SpatialPointsDataFrame 格式的对象的坐标值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23647529/
我正在尝试将与 bat 位置 (SpatialPointsDataFrame) 相关的数据叠加到科罗拉多州 (SpatialPolygonsDataFrame) 上。两个对象的CRS不同: crs(c
我正在尝试将与 bat 位置 (SpatialPointsDataFrame) 相关的数据叠加到科罗拉多州 (SpatialPolygonsDataFrame) 上。两个对象的CRS不同: crs(c
我必须沿着一个曲折的特征来克里格值。因此,我必须将正常的笛卡尔坐标 (x,y) 转换为曲线坐标系 (s,n)。曲线坐标允许我进行克里格法,在克里格法之后,我可以将坐标反转为笛卡尔 x,y 以便表示原始
使用sp R 中的包。我想知道何时使用 SpatialPoints 以及何时使用 SpatialPointsDataframe。我觉得没有太大区别?! 唯一的区别是在 SpatialPointsDat
我有一个 SpatialPointsDataFrame,它有一个属性(为了方便起见,我们称之为 z)以及纬度/经度坐标。 我想将其写入 XYZ 文件(即具有三列的 ASCII 文件)。 最初我试过 w
我有一个 SpatialPointsDataFrame 加载 pst500),nrow(coord)) # check position of breaks breaks = c(1,which(li
我有一个使用以下命令绘制的 SpatialPolygonsDataFrame: spplot(milanoNILNew, "percPolVita",at = c(0,0.0696,0.08979,0
我需要将 R data.frame 对象转换为 SpatialPointsDataFrame 对象,以便对数据运行空间统计函数。但是,出于某种原因,将 data.frame 对象转换为 Spatial
我正在尝试使用 sp 完成的任务非常简单。 R 中的包,但我正在努力学习 sf因此我的问题。我试图在 R 中创建一个点的形状。我有很多点,所以它必须是有效的。我在 sp 中都成功做到了和 sf但是 s
我想要做的任务非常简单,使用 R 中的 sp 包,但我正在尝试学习 sf 因此我的问题。我正在尝试在 R 中创建点的形状。我有很多点,所以它必须高效。我已经在 sp 和 sf 中成功完成了此操作,但
我正在致力于运行 RandomForest。我已经导入了代表已使用和未使用站点的点数据,并从栅格 GIS 图层创建了一个栅格堆栈。我创建了一个 SpatialPointDataFrame,其中包含我所
我正在使用 HURDAT 数据集绘制飓风轨迹。 我目前在 R 中生成了一个 SpatialPointsDataFrame 对象,它在 2004 年看起来像这样。 > str(cluster.2
我一直在关注 this workflow将坐标从东/北转换为 R 中的纬度/经度。直到今天它一直工作正常。这是一个可重现的示例: require(rgdal) # create test coordi
我在 R 中有一个 SpatialPointsDataFrame,如下所示: coordinates id order hole piece group box_id
我使用 R 使用 ggplot2 形式的大圆圈在世界地图上投影一些数据流。 我还想在我的 map 上投影城市区域: http://www.naturalearthdata.com/downloads/
我想使用 ggmap 创建 map 。我想显示一些点的位置,从带有 UTM 坐标的数据框开始。但是,我总是以错误消息结尾:“错误:ggplot2 不知道如何处理 SpatialPointsDataFr
我正在尝试将 1000x1000 米正方形的 SpatialPointsDataFrame(网格)与 SpatialPolygonsDataFrame(信息)结合起来,以聚合每个网格正方形内点的所有信
我是一名优秀的程序员,十分优秀!