Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GRASS locations from EPSG codes #70

Closed
wenzeslaus opened this issue Nov 9, 2022 · 1 comment
Closed

Create GRASS locations from EPSG codes #70

wenzeslaus opened this issue Nov 9, 2022 · 1 comment

Comments

@wenzeslaus
Copy link

As mentioned in #34, it would be nice if rgrass can create GRASS locations (projects?) from EPSG codes.

I used the GRASS executable to do that:

#' Create GRASS GIS location
#'
#' Calls GRASS GIS to create a new GRASS GIS location using either a
#' georeferenced file or EPSG code.
#'
#' @param grassExecutable GRASS GIS executable (full path or command)
#' @param readProjectionFrom A geospatial file with CRS to use
#' @param EPSG EPSG code of a desired CRS
#' @param database Path to GRASS GIS spatial database (directory)
#' @param location Name of newly created location
createGRASSlocation <- function (grassExecutable, readProjectionFrom, EPSG, database, location) {
  locationPath <- file.path(database, location)
  if (missing(EPSG)){
    system(paste("\"", grassExecutable, "\"", " -c ", "\"", readProjectionFrom, "\"", " ", "\"", locationPath, "\"", " -e ", sep = ""))
  }
  else{
    system(paste("\"", grassExecutable, "\"", " -c ", "EPSG:", EPSG, " ", "\"", locationPath, "\"", " -e ", sep = ""))
  }
}
@rsbivand
Copy link
Owner

Thanks! No roxygen here please (also #71 ). No new functions either, both these should be incorporated into initGRASS(). Both also need care that R is not being run within GRASS, need clear documentation in vignettes/use.Rmd, and in the initGRASS() man page. Creating a "SpatRaster" object with the required CRS is probably easier than adding code, unless you have clear use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants