Re: [GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile
Roger, all, greetings from the community sprint: http://grasswiki.osgeo.org/wiki/Talk:GRASS_Community_Sprint_Como_2015 On Fri, Jun 19, 2015 at 9:15 AM, Markus Neteler nete...@osgeo.org wrote: 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. Do you have any suggestions how to add SQLite support for a better vector interface? thanks Markus ___ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats
Re: [GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile
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 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 = { ___ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats
Re: [GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile
On Thu, 18 Jun 2015, Markus Neteler wrote: Dear Roger, On Thu, Jun 18, 2015 at 10:28 AM, Roger Bivand roger.biv...@nhh.no wrote: Dear Markus, You have commit rights, so please consider that route. ok will do! Before committing, I increment Version: in rgrass7/DESCRIPTION, and run: Should I put 0.2-0 or 0.1-1 ? 0.1-1, as this would be a small correction of an existing functionality. R CMD build rgrass7 in spgrass/pkg, creating rgrass7_0.1-*.tar.gz, then start GRASS 7 in the example location (NC basic), and run: R CMD check --run-dontrun --run-donttest rgrass7_0.1-*.tar.gz If it passes without obvious problems caused by the changes made, I commit. My (small) changes do not cause any troubles but there is this unrelated issue: I'll fix this once you commit; it is protected by \dontrun{} in the help file examples, but --run-dontrun overrides that. CRAN often uses --run-dontrun --run-donttest to be sure that the code included in these exceptions is valid. I need to find a way to bracket this properly. Sorry, I should have tried myself first! Roger GRASS 7.0.1RC1 (nc_basic_spm_grass7):~/software/rgrass7_svn/pkg R CMD check --run-dontrun --run-donttest rgrass7_0.2-*.tar.gz * using log directory ‘/home/neteler/software/rgrass7_svn/pkg/rgrass7.Rcheck’ * using R version 3.2.0 (2015-04-16) * using platform: x86_64-redhat-linux-gnu (64-bit) ... * checking for unstated dependencies in examples ... OK * checking examples ... ERROR Running examples in ‘rgrass7-Ex.R’ failed The error most likely occurred in: ### Name: initGRASS ### Title: Initiate GRASS session ### Aliases: initGRASS get.GIS_LOCK set.GIS_LOCK unset.GIS_LOCK ### unlink_.gislock ### Keywords: spatial ### ** Examples initGRASS(/usr/bin/grass-7.0.0, home=tempdir()) Error in initGRASS(/usr/bin/grass-7.0.0, home = tempdir()) : A GRASS location is already in use; to override, set override=TRUE Execution halted * checking PDF version of manual ... OK * DONE Status: 1 ERROR See ‘/home/neteler/software/rgrass7_svn/pkg/rgrass7.Rcheck/00check.log’ for details. I don't know where the override=TRUE needs to be used. It may be worth adding a suitable example to the help page in man/, guarded in case some platform doesn't have the required driver on the rgdal side. I think that GML and GeoJSON are problematic because of the binary-string-binary conversions for coordinates, but we need working cases to start with. Ok, my first commit will just be the small bugfix. Regarding the idea to avoid SHAPE as internal data transfer: The GeoJSON implementation failed because it does not accept a layer name. But I have a (for me) working GML solution implemented which I would prefer to send for inspection: a few lines but they look like a hack to me. Not knowing well what's behind a rgdal call conditionalized upon the rgdal package version, I likely implemented a workaround. At least I can start with my analysis now :-) Of course, if it is more convenient for you, a diff for me to patch in would also be fine. Thanks for pushing (not a git pun) this! I'm happy to commit. Best wishes, Markus -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 91 00 e-mail: roger.biv...@nhh.no ___ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats
Re: [GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile
Dear Markus, You have commit rights, so please consider that route. Before committing, I increment Version: in rgrass7/DESCRIPTION, and run: R CMD build rgrass7 in spgrass/pkg, creating rgrass7_0.1-*.tar.gz, then start GRASS 7 in the example location (NC basic), and run: R CMD check --run-dontrun --run-donttest rgrass7_0.1-*.tar.gz If it passes without obvious problems caused by the changes made, I commit. It may be worth adding a suitable example to the help page in man/, guarded in case some platform doesn't have the required driver on the rgdal side. I think that GML and GeoJSON are problematic because of the binary-string-binary conversions for coordinates, but we need working cases to start with. Of course, if it is more convenient for you, a diff for me to patch in would also be fine. Thanks for pushing (not a git pun) this! Best wishes, Roger On Thu, 18 Jun 2015, Markus Neteler wrote: Dear Roger, On Wed, Jun 17, 2015 at 2:36 PM, Markus Neteler nete...@osgeo.org wrote: geonames - readVECT(mygeonames, driver=GML) Error in paste(gtmpfl1, shname, sep = .Platform$file.sep) : object 'shname' not found I fixed it locally. Do you want a diff or me committing it? Best Markus -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 91 00 e-mail: roger.biv...@nhh.no ___ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats
Re: [GRASS-stats] rgrass7: readVECT() issue with drivers other than ESRI Shapefile
Dear Roger, On Thu, Jun 18, 2015 at 10:28 AM, Roger Bivand roger.biv...@nhh.no wrote: Dear Markus, You have commit rights, so please consider that route. ok will do! Before committing, I increment Version: in rgrass7/DESCRIPTION, and run: Should I put 0.2-0 or 0.1-1 ? R CMD build rgrass7 in spgrass/pkg, creating rgrass7_0.1-*.tar.gz, then start GRASS 7 in the example location (NC basic), and run: R CMD check --run-dontrun --run-donttest rgrass7_0.1-*.tar.gz If it passes without obvious problems caused by the changes made, I commit. My (small) changes do not cause any troubles but there is this unrelated issue: GRASS 7.0.1RC1 (nc_basic_spm_grass7):~/software/rgrass7_svn/pkg R CMD check --run-dontrun --run-donttest rgrass7_0.2-*.tar.gz * using log directory ‘/home/neteler/software/rgrass7_svn/pkg/rgrass7.Rcheck’ * using R version 3.2.0 (2015-04-16) * using platform: x86_64-redhat-linux-gnu (64-bit) ... * checking for unstated dependencies in examples ... OK * checking examples ... ERROR Running examples in ‘rgrass7-Ex.R’ failed The error most likely occurred in: ### Name: initGRASS ### Title: Initiate GRASS session ### Aliases: initGRASS get.GIS_LOCK set.GIS_LOCK unset.GIS_LOCK ### unlink_.gislock ### Keywords: spatial ### ** Examples initGRASS(/usr/bin/grass-7.0.0, home=tempdir()) Error in initGRASS(/usr/bin/grass-7.0.0, home = tempdir()) : A GRASS location is already in use; to override, set override=TRUE Execution halted * checking PDF version of manual ... OK * DONE Status: 1 ERROR See ‘/home/neteler/software/rgrass7_svn/pkg/rgrass7.Rcheck/00check.log’ for details. I don't know where the override=TRUE needs to be used. It may be worth adding a suitable example to the help page in man/, guarded in case some platform doesn't have the required driver on the rgdal side. I think that GML and GeoJSON are problematic because of the binary-string-binary conversions for coordinates, but we need working cases to start with. Ok, my first commit will just be the small bugfix. Regarding the idea to avoid SHAPE as internal data transfer: The GeoJSON implementation failed because it does not accept a layer name. But I have a (for me) working GML solution implemented which I would prefer to send for inspection: a few lines but they look like a hack to me. Not knowing well what's behind a rgdal call conditionalized upon the rgdal package version, I likely implemented a workaround. At least I can start with my analysis now :-) Of course, if it is more convenient for you, a diff for me to patch in would also be fine. Thanks for pushing (not a git pun) this! I'm happy to commit. Best wishes, Markus ___ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats