[GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile

Markus Neteler neteler at osgeo.org
Fri Jun 19 00:15:31 PDT 2015


All,

attached a simple (potentially ugly?) change to enable "SQLite" as a
new driver for reading GRASS GIS 7 vector data into R
(readVECT("vectmap, driver="SQLite")).
I would really appreciate to see "SQLite" support added since it seems
to be the only lossless OGR driver (e.g. unlike the default "SHAPE"
file driver).

I'll not commit this myself to r-forge since I am not sure if it
should be implemented differently.
Please verify.

thanks,
Markus
-------------- next part --------------
Index: pkg/rgrass7/R/vect_link.R
===================================================================
--- pkg/rgrass7/R/vect_link.R	(revision 32)
+++ pkg/rgrass7/R/vect_link.R	(working copy)
@@ -86,7 +86,7 @@
     if (!(driver %in% sapply(ogrDGRASSs, "[", 2)))
         stop(paste("Requested driver", driver, "not available in GRASS"))
     fDrivers <- c("GML", "SQLite")
-    dDrivers <- c("ESRI_Shapefile", "MapInfo_File")
+    dDrivers <- c("ESRI_Shapefile", "MapInfo_File", "SQLite")
     if (!(gsub(" ", "_", driver) %in% c(fDrivers, dDrivers)))
         stop(paste("Requested driver", driver, "not supported"))
     is_dDriver <- TRUE
@@ -138,7 +138,10 @@
                 res <- rgdal::readOGR(dsn=RDSN, layer=LAYER, verbose=!ignore.stderr, 
                                       pointDropZ=pointDropZ)
             } else {
-                res <- rgdal::readOGR(dsn=rtmpfl1, layer=shname, verbose=!ignore.stderr)
+                if (driver == "SQLite")
+                   res <- rgdal::readOGR(dsn=RDSN, layer=tolower(shname), verbose=!ignore.stderr)
+                else
+                   res <- rgdal::readOGR(dsn=rtmpfl1, layer=shname, verbose=!ignore.stderr)
             }
         },
         finally = {


More information about the grass-stats mailing list