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