Load multiple raster in the cell spatial grid

65 views
Skip to first unread message

Etienne DELAY

unread,
Jul 20, 2017, 9:33:17 AM7/20/17
to GAMA

Hi again, 

I have created a grid from my DEM. Now I would like to populate this same grid with other values (from other raster). How can I do that ? Is there any model in the library to take a look ?

E.

Patrick Taillandier

unread,
Jul 20, 2017, 10:11:41 AM7/20/17
to gama-p...@googlegroups.com
Hi,

The simplest way is to use asc files for the other grid files and to read them as matrices. Please find attached an example.

Cheers,

Patrick

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platform+unsubscribe@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

ABM_Moorea2.zip

Etienne DELAY

unread,
Jul 20, 2017, 12:22:44 PM7/20/17
to GAMA

What the hardest way ? Because it's always something horrible to deal with asc ...

E.



Le jeudi 20 juillet 2017 14:11:41 UTC, Patrick Taillandier a écrit :
Hi,

The simplest way is to use asc files for the other grid files and to read them as matrices. Please find attached an example.

Cheers,

Patrick
2017-07-20 15:33 GMT+02:00 Etienne DELAY <abce...@gmail.com>:

Hi again, 

I have created a grid from my DEM. Now I would like to populate this same grid with other values (from other raster). How can I do that ? Is there any model in the library to take a look ?

E.

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.

Patrick Taillandier

unread,
Jul 20, 2017, 1:23:45 PM7/20/17
to gama-p...@googlegroups.com
Hi,

I do not understand why it is horrible to deal with asc file (that are just ascii matrices with a header - QGIS is very good to translate geotiff to asc), but a very bad way to deal with your problem with using only geotiff is to define a grid per geotiff file.....you can after transfer the attribute of each cell of each grid to the main grid.

Cheers,

Patrick  

To unsubscribe from this group and stop receiving emails from it, send an email to gama-platform+unsubscribe@googlegroups.com.

Etienne DELAY

unread,
Jul 20, 2017, 2:03:11 PM7/20/17
to gama-p...@googlegroups.com

In fact Qgis is not good enough ! After a reprojection our grid is  not more a regular grid (cells are rectangular)... and gdal_translate, sometimes overpast :-S

E.

--
Cordialement

Etienne DELAY

Etienne DELAY

unread,
Jul 21, 2017, 8:34:15 AM7/21/17
to GAMA

Hi, 

I have used GRASS-GIS in R to "build" all my ASC needed ! Load data as a matrix with your script work like a charm :-)


If someone needs an example, my script is : 


library(rgrass7)



## remove (almost) everything in the working environment.
## You will get no warning, so don't do this unless you are really sure.
rm(list = ls())


# initialisation of grass data base 
initGRASS(gisBase = "/usr/lib/grass72", home = tempdir(),
          gisDbase = "/home/user/Documents/futurSahel/grassDB/",
          location = "gama_transform", mapset = "PERMANENT", override=TRUE)

execGRASS("g.list", parameters = list(type = "raster")) ##list all reaster in GrassDB


#########################################################################
## resampling
#########################################################################

execGRASS("g.region", parameters = list(res = "50000", vector="square"))

##liste of NDVI/MODIS raster
my.pattern <- "A2016*"
rast.div.l <- attr(execGRASS("g.list", parameters = list(type = "raster", pattern = my.pattern)),"resOut") ## get a raster list from location mapset

for(i in 1:length(rast.div.l)){
  execGRASS("r.resamp.stats", parameters = list(input=paste0(rast.div.l[i]),
                                                output = paste0("resamp_",rast.div.l[i]),
                                                method="mode"),
            flags = c("overwrite","w")) ## resample with resolution
}

## Comput dem 
execGRASS("r.resamp.stats", parameters = list(input="dem_resemple50",
                                              output = "resamp_dem",
                                              method="mode"),
          flags = c("overwrite","w")) ## resample with resolution

#########################################################################
## 

my.pattern <- "resamp_*"
rast.div.l <- attr(execGRASS("g.list", parameters = list(type = "raster", pattern = my.pattern)),"resOut") ## get a raster list from location mapset
for(i in 1:length(rast.div.l)){
  execGRASS("r.out.ascii",parameters = list(input=paste0(rast.div.l[i]),
                                            output = paste0("/home/user/gama_workspace/BestModel/includes/dem/",rast.div.l[i],".asc"),
                                            precision=4),
            flags = c("overwrite"))
}

Patrick Taillandier

unread,
Aug 1, 2017, 10:52:16 AM8/1/17
to gama-p...@googlegroups.com
Hi,

Just to say that I have implemented a way to simply import multiple raster files into a grid: grid cell files: [dem_file,land_cover_file] ;
I have added an example model in the model library: Features/Data Importation/Multiple Raster File Import.gaml.

Cheers,

Patrick

To unsubscribe from this group and stop receiving emails from it, send an email to gama-platform+unsubscribe@googlegroups.com.

Etienne DELAY

unread,
Aug 2, 2017, 7:23:10 AM8/2/17
to GAMA

Nice ! I will try for the LiENs challenge :-p

E.

Reply all
Reply to author
Forward
0 new messages