R转换ppp对象的纬度和经度点以及shapefile

时间:2015-05-30 19:03:12

标签: r

我正在尝试将ppp函数用于R中的空间点数据。我知道需要欧几里德距离而不是纬度和经度。我想知道如何为该区域获取我的点数据和shapefile并将它们转换为可用于ppp对象的东西。

所以我使用下面的代码来获得点数据并且看起来有些合理。我对CRS预测有些不熟悉,并且不确定我是否正确定义了东西。例如,我可以将proj4string定义为longlat或进行转换WGS84。

LatLong<-ASA[,304:305]

#Not sure if this actually is doing what I think I am doing (converting from lat/long to a format with euclidean distance):

id.spp <- SpatialPointsDataFrame(coords = LatLong, proj4string = CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), data = ASA)

#I also tried just using the input as lat long without any second part. both give workable output, but not sure if they are correct
id.spp2 <- SpatialPointsDataFrame(coords = LatLong, proj4string = CRS("+proj=longlat "), data = ASA)

#I then converted both versions using the code below:
ppp<-as(as(id.spp, "SpatialPoints"), "ppp")

plot(ppp)

plot(StudyArea_GCS, add=T)

#Appears to reasonably surround points in anticipated way even though i did not do any type of conversion - it is in lat/long. 

#The lat/long points, appear to be in the same place as the ppp points. 
points(LatLong,pch=".")

谢谢!

0 个答案:

没有答案