Closed bkielstr closed 6 years ago
Hi, thanks a lot for your feedback! However, I am not able to reproduce your problem. Can you please give me some more details? This is what the code and output looks like when I use it:
library("openSTARS")
initGRASS(gisBase` = "c:/Program Files/GRASS GIS 7.2.0",
+ home = tempdir(),
+ gisDbase = "f:/Landau/GRASSDB",
+ location = "test_tutorial"
+ )
gisdbase f:/Landau/GRASSDB
location test_tutorial
mapset file2398512d4a84
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
execGRASS("g.region",flags=c("p","e"))
projection: 0 (x,y)
zone: 0
north: 1
south: 0
west: 0
east: 1
nsres: 1
ewres: 1
rows: 1
cols: 1
cells: 1
north-south extent: 1.000000
east-west extent: 1.000000
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
setup_grass_environment(dem = dem_path, sites = sites_path)
Setting up GRASS Environment...
WARNING: Concurrent mapset locking is not supported on Windows
Trying to open with OGR...
...succeeded.
Default region was updated to the new projection, but if you have multiple
mapsets `g.region -d` should be run in each to update the region from the
default
Projection information updated
execGRASS("g.region",flags=c("p","e"))
projection: 99 (NAD83_HARN_North_Carolina)
zone: 0
datum: nad83harn
ellipsoid: grs80
north: 228500
south: 215000
west: 630000
east: 645000
nsres: 30
ewres: 30
rows: 450
cols: 500
cells: 225000
north-south extent: 13500.000000
east-west extent: 15000.000000
Hi there,
I think that the problem might be that your location already has some spatial information, whereas your tutorial says that:
‘setup_grass_environment prepares the GRASS environment by setting
sessionInfo() R version 3.4.3 (2017-11-30) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C [5] LC_TIME=English_Canada.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] openSTARS_1.0.0 rgrass7_0.1-10 XML_3.98-1.9 data.table_1.10.4-3 sp_1.2-7
loaded via a namespace (and not attached): [1] igraph_1.1.2 Rcpp_0.12.15 magrittr_1.5 progress_1.1.2 maptools_0.9-2 MASS_7.3-47 bit_1.1-12 lattice_0.20-35 [9] R6_2.2.2 rlang_0.1.6 blob_1.1.0 tools_3.4.3 rgdal_1.2-16 grid_3.4.3 SSN_1.1.12 DBI_0.7 [17] rgeos_0.3-26 assertthat_0.2.0 yaml_2.1.16 bit64_0.9-7 digest_0.6.15 tibble_1.4.2 Matrix_1.2-12 memoise_1.1.0 [25] RSQLite_2.0 compiler_3.4.3 pillar_1.1.0 prettyunits_1.0.2 foreign_0.8-69 pkgconfig_2.0.1
Initialize
initGRASS(gisBase = "C:/Program Files/GRASS GIS 7.4.0",
- home = tempdir(),
- override = TRUE) gisdbase C:/Users/brian/AppData/Local/Temp/RtmpovQHFY location file21f47dab1a4c mapset file21f429482990 rows 1 columns 1 north 1 south 0 west 0 east 1 nsres 1 ewres 1 projection NA
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS") sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
dem_path [1] "C:/Users/brian/Documents/R/win-library/3.4/openSTARS/extdata/nc/elev_ned_30m.tif" sites_path [1] "C:/Users/brian/Documents/R/win-library/3.4/openSTARS/extdata/nc/sites_nc.shp"
setup_grass_environment(dem = dem_path, sites = sites_path) Setting up GRASS Environment...
WARNING: Concurrent mapset locking is not supported on Windows
Trying to open with OGR...
...succeeded.
Default region was updated to the new projection, but if you have multiple
mapsets g.region -d
should be run in each to update the region from the
default
Projection information updated
Error: driver %in% candDrivers is not TRUE
gmeta() gisdbase C:/Users/brian/AppData/Local/Temp/RtmpovQHFY location file21f47dab1a4c mapset PERMANENT rows 1 columns 1 north 1 south 0 west 0 east 1 nsres 1 ewres 1 projection +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0,0,0,0,0,0,0 +to_meter=1
import_data(dem = dem_path, sites = sites_path) Loading DEM into GRASS...
Loading sites into GRASS as sites_o ...
No streams available, skipping.
dem <- readRAST("dem", ignore.stderr = TRUE) plot(dem, col = terrain.colors(20)) Error in seq.default(zlim[1], zlim[2], length.out = length(col) + 1) : 'from' must be a finite number In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf
execGRASS("g.region",flags=c("p","e")) projection: 99 (NAD83_HARN_North_Carolina) zone: 0 datum: nad83harn ellipsoid: grs80 north: 1 south: 0 west: 0 east: 1 nsres: 1 ewres: 1 rows: 1 cols: 1 cells: 1 north-south extent: 1.000000 east-west extent: 1.000000
dem Object of class SpatialGridDataFrame Object of class SpatialGrid Grid topology: cellcentre.offset cellsize cells.dim 1 0.5 1 1 2 0.5 1 1 SpatialPoints: s1 s2 [1,] 0.5 0.5 Coordinate Reference System (CRS) arguments: +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0,0,0,0,0,0,0 +to_meter=1
Data summary: Min. 1st Qu. Median Mean 3rd Qu. Max. NA's NA NA NA NaN NA NA 1
From: MiKatt [mailto:notifications@github.com] Sent: February 13, 2018 5:07 AM To: MiKatt/openSTARS openSTARS@noreply.github.com Cc: Brian Kielstra b.kielstra@alumni.ubc.ca; Author author@noreply.github.com Subject: Re: [MiKatt/openSTARS] setup_grass_environment (#4)
Hi, thanks a lot for your feedback! However, I am not able to reproduce your problem. Can you please give me some more details? This is what the code and output looks like when I use it:
library("openSTARS")
initGRASS(gisBase` = "c:/Program Files/GRASS GIS 7.2.0",
home = tempdir(),
gisDbase = "f:/Landau/GRASSDB",
location = "test_tutorial"
)
gisdbase f:/Landau/GRASSDB
location test_tutorial
mapset file2398512d4a84
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
execGRASS("g.region",flags=c("p","e"))
projection: 0 (x,y)
zone: 0
north: 1
south: 0
west: 0
east: 1
nsres: 1
ewres: 1
rows: 1
cols: 1
cells: 1
north-south extent: 1.000000
east-west extent: 1.000000
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
setup_grass_environment(dem = dem_path, sites = sites_path)
Setting up GRASS Environment...
WARNING: Concurrent mapset locking is not supported on Windows
Trying to open with OGR...
...succeeded.
Default region was updated to the new projection, but if you have multiple
mapsets g.region -d
should be run in each to update the region from the
default
Projection information updated
execGRASS("g.region",flags=c("p","e"))
projection: 99 (NAD83_HARN_North_Carolina)
zone: 0
datum: nad83harn
ellipsoid: grs80
north: 228500
south: 215000
west: 630000
east: 645000
nsres: 30
ewres: 30
rows: 450
cols: 500
cells: 225000
north-south extent: 13500.000000
east-west extent: 15000.000000
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MiKatt/openSTARS/issues/4#issuecomment-365214930, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANrG3ae8uMwjGgO5AJIoXzf1Iq5wmuaWks5tUV6ogaJpZM4SCv-N.
Hi
The problem seems to be the error "Error: driver %in% candDrivers is not TRUE" that occurs in setup_grass_environment . I should definitively catch it. writeVECT with driver = "SQLite" does not work. Could you please execute the following code (from writeVECT) and tell me the outcome:
ogrD <- rgdal::ogrDrivers()
ogrDw <- gsub(" ", "_", ogrD$name[ogrD$write])
# guess GRASS v.out.ogr capability from rgdal
ogrDGRASS <- execGRASS("v.in.ogr", flags="f", intern=TRUE,
ignore.stderr=T)
ogrDGRASSs <- gsub(" ", "_", sapply(strsplit(ogrDGRASS, ": "), "[", 2))
candDrivers <- gsub(" ", "_", sort(intersect(ogrDGRASSs, ogrDw)))
print(candDrivers)
Hi,
Here is the full output:
> library("openSTARS")
>
> initGRASS(gisBase = "C:/Program Files/GRASS GIS 7.4.0",
+ home = tempdir(),
+ override = TRUE)
gisdbase C:/Users/brian/AppData/Local/Temp/Rtmpu81PA7
location file3aa876a25ff9
mapset file3aa8114e704c
rows 1
columns 1
north 1
south 0
west 0
east 1
nsres 1
ewres 1
projection NA
>
> ogrD <- rgdal::ogrDrivers()
> ogrDw <- gsub(" ", "_", ogrD$name[ogrD$write])
>
> # guess GRASS v.out.ogr capability from rgdal
> ogrDGRASS <- execGRASS("v.in.ogr", flags="f", intern=TRUE,
+ ignore.stderr=T)
> ogrDGRASSs <- gsub(" ", "_", sapply(strsplit(ogrDGRASS, ": "), "[", 2))
> candDrivers <- gsub(" ", "_", sort(intersect(ogrDGRASSs, ogrDw)))
> print(candDrivers)
[1] "AmigoCloud" "Carto" "ESRI_Shapefile" "Geoconcept" "GeoJSON" "GeoRSS" "GPSBabel" "GPSTrackMaker"
[9] "GPX" "MapInfo_File" "Memory" "ODBC" "Selafin"
Sorry about the terrible e-mail format before.
Regards, Brian
Hi Brian,
the problem is that the SQLite driver is not installed on your system.
I changed the function so that it catches this error and then reads in the DEM temporarily to set the extent.
Would you please reinstall openSTARS from GitHub and try again.
Best, Mira
The latest update should solve this issue. Hence I close it.
From your tutorial, the "setup_grass_environment" does not actually set the extent to the dem. I needed to set up a Location/Mapset with the proper extents before I could load in the dem and sites.