如何在R中将UTM坐标转换为lat和long

时间:2021-03-21 20:09:16

I am trying to run a species distribution model and need to create background points to run my logistic regression model. I have just created 500 randomPoints but they are in UTM coordinates and I need lat and long. Is there a way to convert them to lat and long in R? If so, can you share the code with me? I am fairly new to R. Thanks!

我正在尝试运行物种分布模型,需要创建背景点来运行我的逻辑回归模型。我刚刚创建了500个randomPoints,但它们是UTM坐标,我需要lat和long。有没有办法在R中将它们转换为lat和long?如果是这样,你能与我分享代码吗?我是R的新手。谢谢!

1 个解决方案

#1


If you need long/lat you should probably generate the random points using that coordinate reference system. But otherwise, create a SpatialPoints object and use spTransform. That is, do something like this (replace the ???):

如果需要long / lat,则应该使用该坐标参考系统生成随机点。但是,否则,创建一个SpatialPoints对象并使用spTransform。也就是说,做这样的事情(替换???):

  library(rgdal)
  sputm <- SpatialPoints(randompoints, proj4string=CRS("+proj=utm +zone=??? +datum=WGS84")  
  spgeo <- spTransform(sputm, CRS("+proj=longlat +datum=WGS84"))

#1


If you need long/lat you should probably generate the random points using that coordinate reference system. But otherwise, create a SpatialPoints object and use spTransform. That is, do something like this (replace the ???):

如果需要long / lat,则应该使用该坐标参考系统生成随机点。但是,否则,创建一个SpatialPoints对象并使用spTransform。也就是说,做这样的事情(替换???):

  library(rgdal)
  sputm <- SpatialPoints(randompoints, proj4string=CRS("+proj=utm +zone=??? +datum=WGS84")  
  spgeo <- spTransform(sputm, CRS("+proj=longlat +datum=WGS84"))