1

I want to define my Grass region with g.region and my raster to desaggregated this raster. I have error with g.region function when I try this :

#Create environment  
initGRASS("C:/Program Files/GRASS GIS 7.6",
          override = TRUE,
          gisDbase = "GRASS_TEMP",
          home = setwd(WD),
          mapset = "PERMANENT",
          remove_GISRC = TRUE)

# Modify projection
execGRASS("g.proj", flags = "c", epsg = 2975)

#Load DEM in Grass
execGRASS("r.in.gdal",
          flags = "overwrite",
          parameters = list(input = paste(getwd(), "/Dalles_MNT/Dalles_fusionnees/MNT_2_dalles_test.tif",  sep=""), 
                            output = "GRASS_raster"))

# Define the Grass region with my raster
execGRASS("g.region", raster = paste(getwd(), "/Dalles_MNT/Dalles_fusionnees/MNT_2_dalles_test.tif",  sep=""))
execGRASS("g.region", res = "0.25") #change the resolution of my region

# Desaggregated DEM
execGRASS(cmd = "r.resamp.interp",
          flag = "overwrite",
          parameters = list(input = "GRASS_raster", output="MNT_desag_RGRASS", method = "bilinear"))

# Export my raster in .tif
execGRASS(cmd = "r.out.gdal",
          flag = "overwrite",
          parameters = list(input = "MNT_desag_RGRASS",
                            output = paste(getwd(),"/Output_data/MNT_disaggregate_GRASS.tif", sep=""),
                            format = "GTiff"))

I have error in this part of my code :

> execGRASS("g.region", raster = paste(getwd(), "/Dalles_MNT/Dalles_fusionnees/MNT_2_dalles_test.tif",  sep=""))

ATTENTION: Nom de fichier
           <F:/PTENIG_PY_R/PTENIG_R/Dalles_MNT/Dalles_fusionnees/MNT_2_dalles_test.tif>
           non autorisé. Caractère </> interdit.
ERREUR :Carte raster
        <F:/PTENIG_PY_R/PTENIG_R/Dalles_MNT/Dalles_fusionnees/MNT_2_dalles_test.tif>
        non trouvée

I try this :

> execGRASS("g.region", raster = "MNT_2_dalles_test.tif")

ERREUR :Carte raster <MNT_2_dalles_test.tif> non trouvée

And at final of my code, my raster exported haven't values certainly in relation to this function g.region.

My file MNT_2_dalles_test.tif exist, I can open it with QGIS without problem, and its path is correct.

1 Answer 1

1

I find the solution, it's a object problem ! If some people are interested by this code see below

execGRASS("g.region", raster = "GRASS_raster")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.