2.4.14

Arc GIS 10

I am completely frustrated by this newest version of Arc GIS. My previous version of 9.3 was easy to use, straight-forward and functional. This new version has a complicated menu arrangement and features that were easy-to use and 'available' in version 9 are now not available in the new version!

I have to say, the look and feel of the programme has not been improved either. Floating menu boxes make it easy to lose menus, and the map does not adjust to fit the screen when a new menu is added: for instance, when I add Arc Toolbox, which now seems to be hidden within the Geoprocessing option in the toolbar, I have to adjust the underlying map and the toolbox sits awkwardly at the side of the screen.

I have also been attempting to use a simple feature of GIS all day - all I want to do is clip a shape file by another shape file so that polygons in one file do not overlap with polygons in the second file and it seems impossible! Apparently, the erase tool (which online sources seems to suggest will perform this function) is only available under the advanced software download. Ridiculous!

I am NOT impressed.

7.3.14

Single figure with multiple plots - R ggplot2

So in my efforts to revise some PhD chapters to submit for publication, I've had to figure out how to do some nice graphics in R to reduced, condense and improve the figures in my chapters.

Some simple steps are described below, as well as the example outputs.

I've tested the layout() function in R, as well as facet.grid, but the latter is for when axes on multiple graphs are the same. This is the case with me, and so I've put together each figure independently and then simple added them together and given them the same legends where applicable.

R code as follows:

library("ggplot2")


  • Create the first figure called popPlot - how population changes over time

popPlot <- ggplot(modelPop, aes(x=factor(year), y=currentPop)) + geom_boxplot()
popPlot <- popPlot + theme(panel.background=element_rect(fill='white', colour='black')) + ylab("Population Size") + xlab("Year of Simulation")
***** the following overrides the automatic scale and sets the x axis labels *******
popPlot <- popPlot + scale_x_discrete(breaks=c(11, 20, 30, 40, 50, 60, 70, 80, 90, 100), labels=c("11", "20", "30", "40", "50", "60", "70", "80", "90", "100"))
***** leaving the x axis title as blank() means it doesn't get printed on this figure ******
popPlot <- popPlot + theme(axis.title.x=element_blank(), axis.title.y=element_text(size=30))
popPlot <- popPlot + theme(axis.text.x=element_text(size=25), axis.text.y=element_text(size=25))
****** the following adds the line indicating the mean value for each year of the simulation *****
popPlot <- popPlot + stat_summary(fun.y=mean, geom="line", aes(group=1), colour='red', size=2)
popPlot


  • Create the second figure called popPlot.L - how population changes over a longer time period

popPlot.L <- ggplot(longModelPop, aes(x=factor(year), y=currentPop)) + geom_boxplot()
******* if the axis titles are not set out here, the data column names will be applied automatically ****
popPlot.L <- popPlot.L + theme(panel.background=element_rect(fill='white', colour='black')) + ylab("Population Size") + xlab("Year of Simulation")
popPlot.L <- popPlot.L + scale_x_discrete(breaks=c(11, 100, 200, 300, 400, 500), labels=c("11", "100", "200", "300", "400", "500"))
****note both axis titles are removed in this figure ******
popPlot.L <- popPlot.L + theme(axis.title.x=element_blank(), axis.title.y=element_blank())
popPlot.L <- popPlot.L + theme(axis.text.x=element_text(size=25), axis.text.y=element_text(size=25))
popPlot.L <- popPlot.L + stat_summary(fun.y=mean, geom="line", aes(group=1), colour='red', size=2)
popPlot.L


  • Now plot both figures together
library("grid")
library("gridExtra")

******* this a single line codes for the plotting of both graphs in the same figure *******
grid.arrange(popPlot, popPlot.L, ncol=2, sub = textGrob("Year of simulation", gp=gpar(fontsize=30)))

This produces the figure below:


Concatenate txt files

So I've once again bit a bit silly trying to output a lot of data in as simple a manner as possible from my Repast model. This means I have 500 files, for every run (20) that I now need to analyse.

I've figured out that the easiest method for doing this is to concatenate the files together. These files are intended for me to analyse how agents are moving around the landscape, and if any movement is occurring from south to north, or vice versa.

The easiest method for this seems to be via the terminal on my Mac, and a great, simple and straightforward method is as follows:

Open /Applications/Utilities/Terminal.app

Type 'sort ' (without the quotes, note the trailing space, and do NOT press return)

Drag the file(s) that you want to sort to the terminal window

type '> sorted.txt' (without the quotes)

Press return. Sort will read the files, sort them and put the sorted list into the file called 'sorted.txt' in your home directory.


Easy peasy!

4.2.14

Completion of example model data chapter

So its been a while since my last blog post. On a personal note I have been busy with Christmas and my young daughter and we have also just moved house again - all of which have distracted me from doing the finishing touches to my PhD. I have also just applied for a NERC grant with cardiff University. That was a terrific amount of work in a short space of time, for which I am not going to know the outcome until June!

With all that going on, I'm surprised to have got so far with things.

To make a general update:

I have now completed my third data chapter - the big beast of a chapter that describes my entire model in detail and publishes the model outcomes, sensitivity analysis and validation with empirical data. What a feat! At every turn I felt like mistakes were arising and the model seemed to crash every time I tried to improve things and make output more ecologically realistic. But time waits for no-one and some sage advice form my supervisor has allowed me to close the door on the continually effort for improvement and concentrate on getting it done and moving on to the landscape analysis.

Some bits and pieces from this chapter:

1. territories and population size. females in red, males in blue.



population remains fairly stable, increasing slightly to fill the useable space and has some good stats for individuals inside and outside of the protected areas. agents are younger in the matrix than inside the protected area, have lower energy reserves and less fecundity.

2. Population stats, protected vs non-protected areas



I still have some issues with validation via the empirical data with the number and distribution of agents being captured by model camera traps not matching the empirical data. The fine and local scale movement of agents does not seem to be adequately captured by the model, but considering the landscape scale nature of the simulation and the scale of movements and number of individuals, then its not surprising to get some scaling issues. A higher resolution landscape and were individuals would allow for a bit more work to be done in this area, but this was not the focus of the piece of work so I'm not too worried. As long as the population level events are being captured, and match the empirical population data then I believe we can be happy with the outcome of the model so far.

Its not my intention to get a model that fully encapsulate the complexity of real individual jaguar movements, as this is going to be pretty much impossible. The need to reduce model complexity, but increase model realism is always going to be a battle. We just have to hope that we reduce model complexity in the right places that model outcomes are not adversely affected. 

The next, and last(!) chapter of my thesis will take a look at this by using the model to investigate connectivity and landscape utilisation in a population of jaguars in a far more fragmented area of Belize.  This should give me a better idea of the issues with the model and how these need to be addressed (if any exist).

For now, I'm pleased to have got this chapter done and happy to be moving onto the last phase of my PhD. The end is in sight!