discuss
discuss copied to clipboard
How to open .gdb MapSource with maptools R package gone?
Hello. While my QGis 3.16 can perfectly open MapSource .gdb files, I am struggling to open them in R. Googling found me that I should use gpsbabel
, and the first search keeps directing me to package maptools
(function readGPS()), which you made obsolete though (https://r-spatial.org/r/2023/05/15/evolution4.html). But, I can't seem to open it in neither terra
nor sf
:
library(terra)
x1 <- vect("d:/zal/dell_NTB/tomas/gps/filipiny/orig-data/Filipiny_Petra_GPS_zal_20110427.gdb")
# Error: [vect] Cannot open this file as a SpatVector: D:\zal\dell_NTB\tomas\gps\filipiny\orig-data\Filipiny_Petra_GPS_zal_20110427.gdb
library(sf)
x1 <- st_read("d:/zal/dell_NTB/tomas/gps/filipiny/orig-data/Filipiny_Petra_GPS_zal_20110427.gdb", quiet = FALSE, drivers = "OpenFileGDB")
#Error: Cannot open "D:\zal\dell_NTB\tomas\gps\filipiny\orig-data\Filipiny_Petra_GPS_zal_20110427.gdb"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.
>
So, with maptools
package gone, how to open Garmin MapSource .gdb file in R now?
Please provide a sample file.
The solution appears to be to use GPSbabel externally, converting the Garmin-specific GBD format https://www.gpsbabel.org/htmldoc-1.9.0/fmt_gdb.html to GPX https://www.gpsbabel.org/htmldoc-1.9.0/fmt_gpx.html. GPX is fully supported as a vector format by GDAL: https://gdal.org/drivers/vector/gpx.html#vector-gpx. Maybe the former maptools::readGPS
could be moved to pgirmess
, what fo you think, @pgiraudoux ?
Dear Roger, I hope this finds you well and happy to hear from you. I am afraid that I am technically unable to maintain the function in pgirmess. In an unofficial (non-CRAN) package pgirbric, I have left a non-maintained set of function to read GPS such as readBaseCamp, readEtrex, readVista. Some of them have been in pgirmess before, and I am not even sure they still work (the GPS devices are probably no longer commercialized)... Best, Patrick
Thanks, Patrick. So the only viable solution is for those with GPS data to convert to GPX probably using GPSbabel externally, then read using the GPX driver in GDAL through sf`` or ``terra
.
GDAL has a GPSBabel driver (https://gdal.org/en/latest/drivers/vector/gpsbabel.html) requiring the gpsbabel binary to be installed on the system. It uses internally GPX as the pivot format between GDAL and GPSBabel