0

I am using the raster package to display a textile that I have converted into an ASCII file.

I have no problem displaying the map using ggplot2. The map I have contains a grid 506 * 608. Each grid cell has a value associated with it. This is the only information included in the map, along with the x and y coordinates.

I have displayed the map using the following code in R:

Map <- raster("filename.txt")

map.spdf <- as(Map, "SpatialPixelsDataFrame")

map.df <- as.data.frame(map.spdf)

head(map.df)

gMap <- ggplot(map.df, aes(x=x, y=y)) + geom_tile(aes(fill=layer)) + coord_equal()

gMap <- gMap + theme(panel.background = element_rect(fill='white'))

gMap <- gMap + scale_fill_gradient2(limits = c(0, 60000), low=muted("green"), mid="red", high="white", midpoint=30000)

gMap

Each grid cell value in my map corresponds to the amount of movement in that location by a number of agents I have simulated in a agent-based simulation (ranging from 0 to 20,000). In short, I want to know where agents have moved on the map, and which areas are used most frequently, so the higher the value of the grid cell the more it has been used by agents.

I have a number of maps, each with exactly the same coordinate system, but with a different distribution of agent movements (and so grid cell values) in each raster map, and I want to compare each map to show whether agent movements statistically differ between maps.

Is this possible?

Thanks

Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
  • Be welcome to SO. First I'd recommend you to read [this](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) post on how to get the best answer just posting a good question. Could you provide some data? What you mean by "...statistically differ between maps"? – Paulo E. Cardoso Apr 25 '14 at 17:46
  • Hi, basically what I want to do is to have some statistical way of testing the difference between maps, rather than a simple visual and subjective interpretation – user3573431 Apr 28 '14 at 08:32
  • Hi, you may be interested in `?raster::calc` – Paulo E. Cardoso Apr 28 '14 at 08:42

0 Answers0