Problems about grid data reading and save?

48 views
Skip to first unread message

bangrong

unread,
Aug 3, 2015, 5:11:07 AM8/3/15
to GAMA


Hi,
      In my experiment, I encountered two problems:
      (1) I want to load the .asc file (nclos1433 * nrows1840)(grid file from arcgis), but it was very slow and failed at last with and warning "Problem Occurred: Unhandled event loop exception, GC overhead limit exceeded", an the memory used was 1976M of 2017M. How can I settle this problem?
     (2) Is there any way to save the results of grid in .asc file?
     Thank you very much!

Best regards,
Bangrong

Patrick Taillandier

unread,
Aug 3, 2015, 5:43:44 AM8/3/15
to gama-p...@googlegroups.com
Hi,

First of all, GAMA is not very adapted to read big asc file: in GAMA, all the cells are agents, so it can take a lot of memories to have big grids.

  (1) I want to load the .asc file (nclos1433 * nrows1840)(grid file from arcgis), but it was very slow and failed at last with and warning "Problem Occurred: Unhandled event loop exception, GC overhead limit exceeded", an the memory used was 1976M of 2017M. How can I settle this problem?
You do not have enough memory : you could try to increase the memory dedicated to java (in the gamma.ini file, increase the value of the xmx parameter).

(2) Is there any way to save the results of grid in .asc file?
No direct way (you should add an issue about it), but as asc file are text file, it is possible to save your grid as asc file:

action save_grid {

save "ncols\t" + nb_cols + "\nnrows\t" + nb_rows+ "\nxllcorner\t" + xllcorner + "\nxllcorner\t" + yllcorner + "\ncellsize\t" + cell_size + "\nNODATA_value\t" + no_data to: "my_grid.asc";

loop j from: 0 to: nb_rows - 1 {

loop i from: 0 to: nb_cols - 1 {

save cell[i,j].val to: "my_grid.asc";

}

}

}


--
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 post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

bangrong

unread,
Aug 3, 2015, 8:14:17 AM8/3/15
to GAMA
Dear Patrick,
      Thank you very much! Yes, it maybe the problem of memory, I will increase my memory and have a try.


Best Regards,
Bangrong


在 2015年8月3日星期一 UTC+2上午11:43:44,Patrick Taillandier写道:

bangrong

unread,
Aug 7, 2015, 8:25:41 AM8/7/15
to GAMA
Hi,
     Thanks for your help! I have tried your code to save as .asc file, however, after I run the procedure, the first 6 rows are in the same row in the result of .asc file, it seems that the escape character "\n" doesn't work. Also, the values are in the same column. I don't know why, the procedure are below, and this action is defined in the global part:
  action save_as_asc{ 
      save ("ncols\t"+nb_cols+"\n"+"nrows\t"+nb_rows+"\nxllcorner\t"+xllcorner+"\nyllcorner\t"+yllcorner+"\ncellsize\t"+cellsize +   "\nNODATA_value\t" + no_data) to:"result_grid.asc";  

     loop j from: 0 to: nb_rows-1 {
           loop i from:0 to: nb_cols-1 {
                save cell[i,j].value to:"result_grid.asc";
           }
      }
 }
       Could you point out what's the reason for this problem for me? Thank you very much!

Regards,
Bangrong

在 2015年8月3日星期一 UTC+2上午11:43:44,Patrick Taillandier写道:
Hi,

bangrong

unread,
Aug 7, 2015, 8:25:41 AM8/7/15
to GAMA
the attached file is the result.


在 2015年8月3日星期一 UTC+2上午11:43:44,Patrick Taillandier写道:
Hi,
result_grid.asc

Patrick Taillandier

unread,
Aug 7, 2015, 9:07:50 AM8/7/15
to gama-p...@googlegroups.com
You are right, here the right code:

action save_grid {

save ("ncols\t" + nb_cols + "\nnrows\t" + nb_rows+ "\nxllcorner\t" + xllcorner + "\nyllcorner\t" + yllcorner + "\ncellsize\t" + cell_size + "\nNODATA_value\t" + no_data) to: "my_grid.asc";

loop j from: 0 to: nb_rows - 1 {

string line <- "";

loop i from: 0 to: nb_cols - 1 {

line <- line + " " + cell[i,j].grid_value;

}

save line to: "my_grid.asc";

}

}

bangrong

unread,
Aug 7, 2015, 12:35:28 PM8/7/15
to GAMA
Dear Patrick,
    Thank you very much! It works now! But the escape character "\n" doesn't work as well, I don't know why, so I changed the first line like this:
  save "ncols\t"+nb_cols to:"result_grid.asc";
  save "nrows\t"+nb_rows to:"result_grid.asc";
  save "xllcorner\t"+xllcorner to:"result_grid.asc";
  save "yllcorner\t"+yllcorner to:"result_grid.asc";
  save "cellsize\t"+cellsize to:"result_grid.asc";
  save "NODATA_value\t"+no_data to:"result_grid.asc";
Thank you for your kindly help again!

Best regards,
bangrong

在 2015年8月7日星期五 UTC+2下午3:07:50,Patrick Taillandier写道:
Reply all
Reply to author
Forward
0 new messages