[R-sig-Geo] Create a ppp object in UTM with mixture of zones
Alexandre Santos
@|ex@ndre@@nto@br @end|ng |rom y@hoo@com@br
Fri Jul 30 00:20:27 CEST 2021
Dear Members,
I'd like to use my spatial data set ("sp_ds") as ppp (spatstat Point Pattern object), an I try to do:
# Open spatial data set in GitHub
library(spatstat)
library(sf)
library(sp)
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)
f1 <- ppm(out.ppp~1)
E <-envelope(f1, Kinhom, nsim = 19, global = TRUE, correction = "border")
plot(E)
#But I'd like to r distance (x axis) in kilometers and for this I need to convert the coordinate reference system of 4326 to
UTM, a have 3 UTM zones:
#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)
Please the area a simple way to create a ppp object in UTM with a mixture of zones?
Thanks in advance,
Alexandre
More information about the R-sig-Geo
mailing list