discuss icon indicating copy to clipboard operation
discuss copied to clipboard

How to open .gdb MapSource with maptools R package gone?

Open telenskyt opened this issue 11 months ago • 4 comments

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?

telenskyt avatar Mar 18 '24 18:03 telenskyt

Please provide a sample file.

rsbivand avatar Mar 18 '24 18:03 rsbivand

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 ?

rsbivand avatar Mar 20 '24 09:03 rsbivand

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

pgiraudoux avatar Mar 20 '24 09:03 pgiraudoux

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.

rsbivand avatar Mar 20 '24 09:03 rsbivand

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

rouault avatar Oct 05 '24 15:10 rouault