使用混合区域在 UTM 中创建一个独特的对象
Create a unique object in UTM with mixture of zones
我想将我的空间数据集 (sp_ds
) 用作 ppp
(spatstat 点模式对象)以进行完整的空间测试,我尝试这样做:
# Packages
library(spatstat)
library(sf)
library(sp)
library(raster) ## maybe a cause of pointDistance() function, not used yet
# Open spatial data set in GitHub
sp_ds<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
str(sp_ds)
#'data.frame': 4458 obs. of 2 variables:
# $ Lat : num 9.17 9.71 9.12 9.12 9.71 ...
# $ Long: num 35.8 35.5 35.8 35.8 35.5 ...
# Create boudaries using sf
sfds = st_as_sf(sp_ds, coords=c("Long","Lat"), crs=4326)
traps<-sp_ds
ch <- chull(traps[,c(2,1)])
coords <- traps[c(ch, ch[1]), ]
coordinates(coords) <- c("Long","Lat")
proj4string(coords) <- CRS("+init=epsg:4326")
W <- owin(poly=cbind(coordinates(coords)[,2],coordinates(coords)[,1]))
# Create a ppp Point Pattern object
out.ppp<-ppp(x=sp_ds$Lat,y=sp_ds$Long,window=W)
plot(out.ppp)
# Make a CRS test
f1 <- ppm(out.ppp~1)
E <-envelope(f1, Kinhom, nsim = 19, global = TRUE, correction = "border")
plot(E)
但我想要以米为单位的 r 距离(x 轴),为此我需要将 4326 的坐标参考系转换为
UTM,但有 3 个 UTM 区域混合:
#34N bounds: (18.0, 0.0, 24.0, 84.0)
#35N bounds: (24.0, 0.0, 30.0, 84.0)
#36N bounds: (30.0, 0.0, 36.0, 84.0)
请问,有没有一种简单的方法可以在 UTM 中创建一个独特的 ppp
对象,其中包含没有区域叠加的区域混合?
提前致谢!
对于穿越区域,meters/kilometres 的更好选择是本地自定义投影,例如 laea:https://twitter.com/mdsumner/status/1136794870113218561?s=19
# Packages
library(spatstat)
library(sf)
library(sp)
# Open spatial data set in GitHub
sp_ds<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
str(sp_ds)
#'data.frame': 4458 obs. of 2 variables:
# $ Lat : num 9.17 9.71 9.12 9.12 9.71 ...
# $ Long: num 35.8 35.5 35.8 35.8 35.5 ...
# sf object convertion
sp_ds <- st_read("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
sp_ds_sf <- st_as_sf(sp_ds, coords = c("Lat", "Long"), crs = 4326)
# Here the laea transformation:
sp_ds_laea = st_transform(sp_ds_sf,
crs = "+proj=laea +x_0=3600000 +y_0=3600000 +lon_0=29.9 +lat_0=13.4 +datum=WGS84 +units=m")
# Create boudaries using sf
ch_ds <- st_convex_hull(st_union(sp_ds_laea))
W<- as.owin(ch_ds)
# Create a ppp Point Pattern with sf object
out.ppp <- as.ppp(X=st_coordinates(sp_ds_laea),W=W)
plot(out.ppp)
# Make the CRS test
f1 <- ppm(out.ppp~1)
E <-envelope(f1, Kinhom, nsim = 19, global = TRUE, correction = "border")
plot(E)
我想将我的空间数据集 (sp_ds
) 用作 ppp
(spatstat 点模式对象)以进行完整的空间测试,我尝试这样做:
# Packages
library(spatstat)
library(sf)
library(sp)
library(raster) ## maybe a cause of pointDistance() function, not used yet
# Open spatial data set in GitHub
sp_ds<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
str(sp_ds)
#'data.frame': 4458 obs. of 2 variables:
# $ Lat : num 9.17 9.71 9.12 9.12 9.71 ...
# $ Long: num 35.8 35.5 35.8 35.8 35.5 ...
# Create boudaries using sf
sfds = st_as_sf(sp_ds, coords=c("Long","Lat"), crs=4326)
traps<-sp_ds
ch <- chull(traps[,c(2,1)])
coords <- traps[c(ch, ch[1]), ]
coordinates(coords) <- c("Long","Lat")
proj4string(coords) <- CRS("+init=epsg:4326")
W <- owin(poly=cbind(coordinates(coords)[,2],coordinates(coords)[,1]))
# Create a ppp Point Pattern object
out.ppp<-ppp(x=sp_ds$Lat,y=sp_ds$Long,window=W)
plot(out.ppp)
# Make a CRS test
f1 <- ppm(out.ppp~1)
E <-envelope(f1, Kinhom, nsim = 19, global = TRUE, correction = "border")
plot(E)
但我想要以米为单位的 r 距离(x 轴),为此我需要将 4326 的坐标参考系转换为 UTM,但有 3 个 UTM 区域混合:
#34N bounds: (18.0, 0.0, 24.0, 84.0)
#35N bounds: (24.0, 0.0, 30.0, 84.0)
#36N bounds: (30.0, 0.0, 36.0, 84.0)
请问,有没有一种简单的方法可以在 UTM 中创建一个独特的 ppp
对象,其中包含没有区域叠加的区域混合?
提前致谢!
对于穿越区域,meters/kilometres 的更好选择是本地自定义投影,例如 laea:https://twitter.com/mdsumner/status/1136794870113218561?s=19
# Packages
library(spatstat)
library(sf)
library(sp)
# Open spatial data set in GitHub
sp_ds<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
str(sp_ds)
#'data.frame': 4458 obs. of 2 variables:
# $ Lat : num 9.17 9.71 9.12 9.12 9.71 ...
# $ Long: num 35.8 35.5 35.8 35.8 35.5 ...
# sf object convertion
sp_ds <- st_read("https://raw.githubusercontent.com/Leprechault/trash/master/myspds.csv")
sp_ds_sf <- st_as_sf(sp_ds, coords = c("Lat", "Long"), crs = 4326)
# Here the laea transformation:
sp_ds_laea = st_transform(sp_ds_sf,
crs = "+proj=laea +x_0=3600000 +y_0=3600000 +lon_0=29.9 +lat_0=13.4 +datum=WGS84 +units=m")
# Create boudaries using sf
ch_ds <- st_convex_hull(st_union(sp_ds_laea))
W<- as.owin(ch_ds)
# Create a ppp Point Pattern with sf object
out.ppp <- as.ppp(X=st_coordinates(sp_ds_laea),W=W)
plot(out.ppp)
# Make the CRS test
f1 <- ppm(out.ppp~1)
E <-envelope(f1, Kinhom, nsim = 19, global = TRUE, correction = "border")
plot(E)