r-spatial / discuss

a discussion repository: raise issues, or contribute!
54 stars 12 forks source link

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

Open telenskyt opened 8 months ago

telenskyt commented 8 months ago

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?

rsbivand commented 8 months ago

Please provide a sample file.

rsbivand commented 8 months ago

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 ?

pgiraudoux commented 8 months ago

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

rsbivand commented 8 months ago

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.

rouault commented 1 month ago

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