1

I am new to using GIS aspect of Repast. The agents have to get pixel values from multiple shapefiles and 2 raster files (based on lat, long), to decide their movement course at every tick. So far, I first created a geography, then added the raster coverage to the geography.

My questions are as follows:

  1. My agents will be moving in this geography, so do I need to create writable grid coverage (for rasters and shapefiles) and then add it to the geography?

  2. Is it possible to add 2 raster files and 3-4 shapefiles to the geography?

  3. How do I read data from a raster file? E.g. NDVI index from a vegetation raster file. (I was looking at the Raster Layer class.)

  4. All of the above mentioned files are created by year. So, I need to recreate these layers according to appropriate tick. Is this approach correct? However, my main question is , how do I display raster data in repast simphony? Some resources would be useful.

I have used the org.geotools package to read raster file in geotif format.

GeoTiffReader geoTiffReader = new GeoTiffReader(new File(filename));
GridCoverage2D coverage = (GridCoverage2D) geoTiffReader.read(null);
geography.addCoverage("coverage1", coverage);

Right now, there are no error messages, so I am assuming the code runs correctly (displays print stmts) and reads the raster file. However, displaying the raster data would be great.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
Swapna
  • 31
  • 1

1 Answers1

3

For references, I suggest staring with the Repast Geography demo model, the GIS documentation on coverages (https://repast.github.io/docs/RepastReference/RepastReference.html#gis-raster), and the GeoTools GridCoverage API (http://docs.geotools.org/latest/userguide/library/coverage/grid.html). Repast Geography projections and displays are fully compatible with GeoTools GridCoverage2D implementations. You can use the GeoTools readers to create the coverages as you described in your example, or you can use the RepastCoverageFactory to create WritableGridCoverage2D, which are simply custom implementations of GridCoverage2D in Repast that allow agents to write to the coverage in memory.

If your agents only need to read from a coverage, then you can use the GeoTools readers to load the raster files and assign to the geography via geography.addCoverage("MyCoverage", coverage), and you can add as many as you like. You can also add as many agent layers from shapefiles as you like to the geography. This is also demonstrated in the Repast Geography demo.

One caveat is that the raster data for the coverages and the shapefiles for the agents should use the same CRS and projection. The Repast Geography assumes that all GIS data in the geograpy is in the same projection. Furthermore, the GIS3D display requires the data be in WGS84. GeoTools provides utilities for converting on the fly, but I would recommend re-projecting in an external GIS tool like ArcGIS or QGIS if needed.

To reference a loaded coverage, an agent may call geography.getCoverage(coverageName), and you can remove a coverage with geography.removeCoverage(coverageName). Once the agent has the coverage instance, it can read values from it directly via

double[] value = null;
DirectPosition pos = new DirectPosition2D(loc.x, loc.y);
coverage.evaluate(pos,value);

The type of value will depend on the data that's in the raster file, e.g. float, int, byte, etc. The value array will contain all of the values for each band that corresponds to the location, so you need to know how the raster file is indexed - usually the specs will be available from where you downloaded the file. In the case of an NDVI raster file, the index is probably a double or float, and might be the only value in the array.

You can certainly add and remove coverage layers at different ticks to simulate change over time. Just make sure that the ordering of agent-behaviors takes this into account, e.g. the coverages should be updated at the beginning of the tick so the agents use the new data each tick. You can create a layer manager agent who takes care of the updating. There should not be any issue with removing and adding layers based on tick, although I haven't tested this with displays so I'm not sure affect this will have visually.

To display the coverage layers you need to use a GIS3D display and then simply add the coverage layers with the display wizard in the Repast runtime. You can include multiple coverage layers in a single display. Coverage layers require a CoverageStyle to determine how the data in the raster translates to an image. Some raster files are indexed on self-contained specific color maps and you can first try using the DefaultCoverageStyle which is the default option in the Display wizard. Alternatively, you can provide the CoverageStyle class and use it to specify how the raster data determines the display colors. The CoverageStyle returns a GeoTools RasterSymbolizer instance and an example is available in the Geography demo in the BlueCoverageStyle class.

Eric Tatara
  • 715
  • 3
  • 12