changing soil_height of cells

22 views
Skip to first unread message

Amélia Graber

unread,
Oct 29, 2025, 11:01:20 AM (12 days ago) Oct 29
to GAMA
Hello! 

I have two questions regarding how to manipulate a grid: 

1. How can I change the cell_height of single cells in a grid according to action of agents. At the moment I am doing it as follows: 

My species plot has an attribute with is cells_list, which designates all the cells overlapping the plot. 
at every 2nd timestep, the following action is called: 

action color_update {

color_plot <- plot_colors[land_use -1];

color_plot_soil <- soil_colors[soil_height];

loop i over: cells_list {

i.col <- plot_colors[int(i.plain)];

i.soil_col <- color_plot_soil;

i.cell_height <- soil_height;

}

}


The highlighted line does not work, and I am wondering how I can change the cell_height of the grid,

by calling the cells through another agent.


2. How can I give the cells of the grid an attribute according to if they are located in a certain shapefile or not? 
I am trying to do this, because not all cells in the grid are part of my study, and so I want to be able to exclude some, by giving them a specific attribute.
At the moment my code is as follows and all cells of the grid get the attribute "true" even though the "plains" shapefile is not a rectangle: 

file cells_shapefile <- file("one_mun/plain_shp/one_plains_constance_study__Clip.shp");
create plains from: cells_shapefile;

grid cells cell_width: 25 cell_height: 5 {

bool plain <- false;

init {

ask cells overlapping geometry(plains) {

plain <- true;

}

}

}


Thank you in advance for the help!


brouillet_study_area_with_flood.gaml

Benoit Gaudou

unread,
Oct 30, 2025, 1:42:02 AM (11 days ago) Oct 30
to gama-p...@googlegroups.com
Dear,
For your first question, the point is that the species/grid cells does not contain the cell_height attribute. So GAMA cannot recognize this variable : "- Unknown variable 'cell_height' in grid cells". Simply add a new attribute in cells.

For the second question, from my point of view, it is strange to change the attribute of all the cells agents, at the init of each cells agent.
Rather, in the init I would check that the current cells that you initialize (self) is overlapped by any plains using : 

init {

// ask cells overlapping geometry(plains) {

if empty(plains overlapping self) {

plain <- true;

}

}

cheers
Benoit

--
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.
To view this discussion visit https://groups.google.com/d/msgid/gama-platform/69c447cd-3e28-409b-9e5d-57fd4e494b1dn%40googlegroups.com.

Amélia Graber

unread,
Oct 31, 2025, 11:30:47 AM (10 days ago) Oct 31
to GAMA
Hello,

Ok, great thank you for the help. 

This might be quite a simple question, but unfortunately I was not able to find it on the gama website: how can I then save that value (cell_height) in an .asc file ?

Thank you in advance for the answer.

Best wishes,
Amélia

Benoit Gaudou

unread,
Nov 3, 2025, 5:35:07 AM (7 days ago) Nov 3
to gama-p...@googlegroups.com
Dear,
You can have a look at the the model library of GAMA, with models related to data save (Save to ASC.gaml).
Note that it will allow you to save automatically data of the grid_value attribute, not any attribute... 
For any attribute, you need to save at hand values.

Cheers
Benoit

Amélia Graber

unread,
Nov 3, 2025, 11:15:04 AM (7 days ago) Nov 3
to GAMA
Dear Benoit, 

Ok, thank you for the answer. I was able to do it by setting the right grid_value.

Best wishes,
Amélia
Reply all
Reply to author
Forward
0 new messages