导出到GPX文件

发布于 2025-02-02 06:21:35 字数 2315 浏览 4 评论 0原文

当我使用gpx软件包以这种格式将.GPX文件从Naviagation软件导入R中,

dput(test)
list(routes = list(structure(list(Elevation = c(NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_), Time = structure(c(NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), Latitude = c(50.76098, 50.76327, 50.766489, 
50.771325, 50.771792, 50.773814, 50.774321, 50.774669, 50.775666, 
50.774327), Longitude = c(-1.322124, -1.32737, -1.324514, -1.316833, 
-1.314606, -1.300727, -1.294736, -1.290568, -1.27571, -1.263494
), extensions = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA, 
-10L))), tracks = list(structure(list(Elevation = logical(0), 
    Time = logical(0), Latitude = logical(0), Longitude = logical(0)), class = "data.frame", row.names = integer(0))), 
    waypoints = list(structure(list(Elevation = logical(0), Time = logical(0), 
        Latitude = logical(0), Longitude = logical(0)), class = "data.frame", row.names = integer(0))))

我想做的是将GPX导出到同一软件。我尝试使用pgirmess软件包,但似乎不再支持tritgpx命令。

然后,我尝试在此处操纵此问题中给出的答案 r用使用GPX转换为GPX时间戳记

但是我不想导出一条轨道,而是人们遵循的途径,因此时间戳记与时间戳无关。

我还尝试使用rgdal软件包,如下所示。

我的数据


dput(routes)
list(structure(list(Elevation = c(NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_), Latitude = c(50.768333, 50.771833, 
50.7735, 50.769167, 50.77, 50.769167), Longitude = c(-1.307167, 
-1.295833, -1.292667, -1.286667, -1.295833, -1.2775), Name = c("3X Donna", 
"3Z Trinity House Buoy", "33 Prince Consort", "34 Cowes Corinthian", 
"39 Snowden", "4K Royal London YC")), class = "data.frame", row.names = c(53L, 
55L, 58L, 59L, 60L, 70L)))

我在下面运行代码,但仍然没有喜悦,

library(rgdal)

coordinates(routes) <- ~Latitude+Longitude
  proj4string(routes) <- "+proj=longlat +datum=WGS84" 

writeOGR(routes, dsn = "routes.gpx", layer = "routes", driver = "GPX", 
         dataset_options = "GPX_USE_EXTENSIONS=yes")

理想情况下,我希望导出一条路线而不是轨道。

When I import a .gpx file from my naviagation software into r using the gpx package it arrives in this format

dput(test)
list(routes = list(structure(list(Elevation = c(NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_), Time = structure(c(NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), Latitude = c(50.76098, 50.76327, 50.766489, 
50.771325, 50.771792, 50.773814, 50.774321, 50.774669, 50.775666, 
50.774327), Longitude = c(-1.322124, -1.32737, -1.324514, -1.316833, 
-1.314606, -1.300727, -1.294736, -1.290568, -1.27571, -1.263494
), extensions = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA, 
-10L))), tracks = list(structure(list(Elevation = logical(0), 
    Time = logical(0), Latitude = logical(0), Longitude = logical(0)), class = "data.frame", row.names = integer(0))), 
    waypoints = list(structure(list(Elevation = logical(0), Time = logical(0), 
        Latitude = logical(0), Longitude = logical(0)), class = "data.frame", row.names = integer(0))))

What I want to do is export a gpx back to the same software. I have tried using the pgirmess package but it no longer supports the writeGPX command seemingly.

Then I tried to manipulate the answer given in this question here R Convert GPS to GPX with timestamp

but I am not looking to export a track but a route for people to follow so the timestamp is not relevant.

I also tried using the rgdal package as shown below.

my data


dput(routes)
list(structure(list(Elevation = c(NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_), Latitude = c(50.768333, 50.771833, 
50.7735, 50.769167, 50.77, 50.769167), Longitude = c(-1.307167, 
-1.295833, -1.292667, -1.286667, -1.295833, -1.2775), Name = c("3X Donna", 
"3Z Trinity House Buoy", "33 Prince Consort", "34 Cowes Corinthian", 
"39 Snowden", "4K Royal London YC")), class = "data.frame", row.names = c(53L, 
55L, 58L, 59L, 60L, 70L)))

The I run the code below but still no joy

library(rgdal)

coordinates(routes) <- ~Latitude+Longitude
  proj4string(routes) <- "+proj=longlat +datum=WGS84" 

writeOGR(routes, dsn = "routes.gpx", layer = "routes", driver = "GPX", 
         dataset_options = "GPX_USE_EXTENSIONS=yes")

I would like ideally to export a route not a track.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文