Showing posts with label Technical Information. Show all posts
Showing posts with label Technical Information. Show all posts

25.4.14

Displaying movement map in R as raster

So I've been busy trying to output suitable information from my model to demonstrate the area sin which agents are moving. I want to get some idea of how well used the map is, and if agents are able to successfully negotiate the central section of the landscape where heterogeneity is highest.

I've outputted a text file that has the number of steps taken in each grid cell and converted this to an ASCII file, replacing all commas with spaces and adding the relevant information at the start of the file as below:


ncols         608
nrows         506
xllcorner     299006.96538007
yllcorner     1898128.1510276
cellsize      100
NODATA_value  0

I can now read this into R with the following:
(which requires several packages - raster, rgdal and scales)


Map1 <- raster ("/Users/aw4g09/Dropbox/ThesisChapters/CorridorLandscapePaper/simulationData/RawData/long_corridorModelOutput/GISMovementMap_1.txt")

and display with several options:
plot(Map1)
or

map.spdf <- as(Map1, "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, 30000), low=muted("green"), mid="red", high="white", midpoint=15000)
gMap
This latter option allows me to manipulate the legend extent, choose gradient colours etc.

I also found a VERY cool way to generate a 3D plot of the raster which can be manipulated. This requires some extra packages including rasterVis, rgl and sp, at which point you can simply enter plot3D(Map1). Another application opens to display the 3d plot.

although I am still struggling to figure out how to save an image of the output!

now I'm starting to try and figure out how to compare movement across simulations, i.e. compare the distribution and density of movements between different rasters... I found a very useful website that is helping with this

http://evansmurphy.wix.com/evansspatial#!raster-analysis-in-r/c1n3l

so I'm hoping I should have something more solid to present in my last thesis chapter than a subjective description of movement... fingers crossed.



3.4.14

Clip polygon layer by another polygon layer

Ok, so I did this once, didn't write it down and then couldn't figure out how to do it again.

I continue to lament on the 'improvements' to arcGIS. Version 10 is not my idea of good software design.
Anyway, I have a number of polygon shape files, that design buffers around existing agricultural areas in the landscape. However, I want to remove the existing urban read from these files to ensure that agricultural expansion cannot override existing landscape features - roads, protected areas, urban centres etc. I don't have the 'erase' tool seeing as this requires the advanced version of arcGIS10.

So what I figured out I need to do is use the 'clip' function, but in reverse; i.e. create a shape file that identifies all the areas outside of protected areas, urban centres, etc and then clip the agricultural files by this 'non' file.

Analysis Tools - Extract - Clip

Finally!

A bit of a workaround, but this seems the best that arcGIS10 has to offer.

To create the 'non' file, use the Union function:

Analysis Tools - Overlay - Union
select Urban polygon file
select corridor outline shapefile

output file identifies urban areas on top of corridor file
then simply remove the urban areas via the attribute table - select urban polygon and delete from the file. done!

then need to do this again with the corridor designs 1 and 2.

repeat with the urban area - removing existing agricultural areas as well as protected reserves and corridor designs (in separate files).

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!

22.2.13

LaTeX

I have just become aware of the TeX tips handle on twitter which I have also just started following. As the name suggests it provides useful tips on using LaTeX.

A useful website it has just informed me of can be found here: /http://www.latextemplates.com/ revealing some very useful LaTeX templates: articles, books, presentations, lab notes, PhD thesis!

great tip. Thanks @TeXtip!

21.6.12

Some simple statistics in R

so, I'm currently running a series of simulations of my ABM to try and identify why my agents are not doing what I expect them to do (hardly surprising really, seeing as my model seems to be getting more and more complicated each time I try to improve things).

Anyway, this has led me down the statistics route for the first time in a long time actually as without it I'm struggling to tell if any of my results are *actually* different from each other. I've done an initial 30 runs of each set of parameter settings, taking 30 to be enough of a sample size to allow me to perform robust statistical analyses. *this is tedious by the way*

So I've had to re-learn R, as I tend to do each time I have some stats to do. It does get easier each time, but I tend to avoid using scripts so I struggle to remember how to do even the most simple of stats. Hence, the incentive to write this post as a reminder to me of how to do some simple functions in R.


data <- read.table("testSimulations.txt", header = T)
attach(data)
plot(data)
summary(data)

*this creates a single plot, over-writing one plot on top of the other onto the same axes*
par(mfrow=c(1,1))
plot(meanTerritory~pherValue, col = "green")
par(new = T)
plot(femaleTerritory~pherValue, axes = F, col = "red")

*this creates a side-by-side plot of individual graphs*
par(mfrow=c(1,2))
plot(meanTerritory~pherValuecol = "green")
plot(femaleTerritory~pherValuecol = "red")


*a simple linear model, the anova command gives a single p-value for the treatment, the summary command compares all separate groups to the first group*
territories <- lm(meanTerritory~pherValue)
anova(territories)
summary(territories)
plot(territories)

*a pairwise t-test analysis compares all groups to each other
tmales <- pairwise.t.test(maleTerritory, pherValue, p.adj="none")

some simple advice:
  • use .txt. files, rather than .csv files
  • use a script - in Mac, cmd-Enter runs a single line of the script
  • any statistical book should help with interpretation of the anova output

15.6.12

GIS update - transforming coordinate systems

Following on from a previous post about getting my data files ready to use in my model, I need to update the transform coordinates instructions.

I previously stated that this could be done effectively from within ArcMap. However I have been having problems getting this to work correctly through the transform command within ArcMap (View - Data Frame Properties - Coordinate System - Transformations).

Some of the data I have been provided with has an underlying coordinate system of WGS_1984_UTM_Zone_16N, but camera data I have has been supplied in NAD_1927_UTM_Zone_16N and so my data files need converting to the later coordinate system.

There is a difference between the Geographic Coordinate System and the Projected Coordinate System. The supplied WGS_1984 is from the Geographic Coordinate System and transforming this only allows you access to other Geographic Coordinate Systems. The correct NAD1927 coordinate system is not geographic but projected and so the transformation function within ArcMap does not adequately transform the data....

so... this can be done more effectively from within ArcCatalog...

Navigate to the appropriate file in ArcCatalog, i'll run through this for my data layer of rivers

1. Select modelRivers.shp
2. Click on File - Properties
3. Select XY Coordinate
4. Choose Select
5. Chose Projected Coordinate Systems - UTM - NAD 1927 - NAD 1927 UTM Zone 16N.prj
6. Click Add
7. Click Apply - OK

Note, you cannot change the coordinate system if the file is already open in ArcMap, so you need to remove the layer from ArcMap before attempting to change the coordinate system.


12.6.12

batch update

Ok, so i did say i was going to post the relevant files that enabled my model to run in batch mode.
I've just come back to this after a few months and have had to re-learn how to do batch runs, so... heres the relevant information:

Batch mode depends mainly on 2 files
1. batch_params.xml - located within the batch folder
2. parameters.xml - located within the JaguarMovementValidation.rs folder

The parameters file must include those parameters that have been set as requiring user input in the ContextCreator file
Batch_params.xml must then include reference to any parameters that are included within the parameters.xml file

Batch mode does not seem to work properly if you try to by-pass these parameters. For instance, I just want to do multiple runs with the same parameters and tried to by-pass the numberOfJaguars parameter by keeping it the same and removing the end and step variables. Batch mode then reports an error and won't run.

For a simple test of running a single simulation, but increasing the jaguar numbers from 50 to 300 in steps of 50, the batch_params.xml file looks like this:


<?xml version="1.0"?>
<sweep runs="10">
<parameter name = "NumberOfJaguars" type="number" start="50" end="300" step="50">
</parameter>
</sweep>

when viewed from the Repast GUI it looks like this:



The parameters.xml file, when viewed within the Repast GUI looks like this:




What I now want is to simply run my simulation 30 times using the same parameters.. I do this by removing the parameters from the ContextCreator file and removing all links to this parameter from both the parameters.xml file and the batch.xml file.

This works, but I'm now having the problem that the output is being generated once per tick for the first 50 ticks only, whereas I want the output once at the final tick count of 5000 (or 2000, depending on my criteria).... shall update once I have this issue resolved.

19.1.12

Repast Batch runs

Ok, so I have successfully got my model to work in batch mode ! :)

Am VERY happy!

The key things seems to be that you can only access parameters from the batch_params.xml file that have been explicitly set up within the model to be controlled by the user (i.e. included within the parameters.xml file in the 'projectName'.rs folder of the project.

Also, if there are any parameters set up in this way that are not included in the batch_params.xml file, the model will not run in batch mode. This only seems to apply to parameters included in the contextCreator file, not those set up within other classes of the model.

Some information seems to be misleading.... in the previous batch post I alluded to a webpage that might be useful from the repast.sourceforge website. This information relates to running a model in batch mode but goes through a quite complicated scenario of installing GridGain and using this to run the model.
This is NOT required to run a simple batch run within eclipse on the local computer. It appears to be most useful for distributing the model to other sources, and using grid computing to run batches...

I doubt I'll need anything quite this complicated as of yet....

Today is a good repast day!

11.1.12

Repast Development and Batch Runs

So its back to the grindstone following a not-long-enough christmas and new year break. This month its all about finalising my model and getting it to a state where I can send off a batch run of the model to Southampton University's super computer. Not only will this mean I get my model to work much more efficiently but that I also won't have to sit around for ages watching the GUI display and waiting... and waiting.... and waiting... whilst tediously repeating... repeating... and repeating runs whilst manually changing parameters.
Excellent.

Only problem is, Repast, once again, seems to be letting me down on documentation! This has to be THE major disadvantage of using this software over others such as MASON (whom several people have suggested I use, but I'm loathe to, considering the time and effort I've spent in learning Repast and the fact that MASON seems to be heavily social simulation focused).

However, there are some other kind people out there who, also noticing the severe lack of Repast documentation, have been amazingly generous by recording and allowing public access to their findings. Pamela Toman, I am very grateful to you for this post about doing batch runs in Repast. Some other useful pages exist including one of Repast Simphony's own online pages found here that outlines the format of how to amend the batch_params.xml file, even if it doesn't go into detail about how to get this to work, or what the file should look like once its been constructed.

Basically, its all a bit more complicated that it needs to be. Repast has an option of a Batch run from the run menu in Eclipse. This requires you to show it where it can find the batch parameters run file (batch_params.xml located in the batch folder within the model architecture in eclipse). I've yet to get to the point of trying this out but it seems that if you just want to run a batch run within eclipse, this MAY be all you need to do.

Exporting the model to run in batch via an external source (i.e. a super-computer) seems much more complicated and there are several files that need amending in order for this to work. So far, I've done the amending, but not been able to test if the export works. Thats next on my list of jobs to do.

Pamela Tomans post outlines all of this, but in brief:

1. The main amendments involved the start_model.bat or start_model.command files (.bat in Windows, .command in Mac/Linux). The model needs to know explicitly where to look for all necessary files, which need to be manually added (running in GUI doesn't require this step). The repast.simphony.repast.RepastMain command also needs to be changed to repast.simphony.batch.BatchMain so it knows to run in batch mode (see Pamela Tomans post for more details on how to amend this file).

2. Actually, what you need to do is create a new start_model.command/bat file. You can call it whatever you want, but if you want the model to be able to run in both GUI and batch, you can't amend the original start_model.command file. If you do, it will no longer run in GUI mode.

3. Now you have added a new file for batch, you need to add this to two other files, so the model knows to look at this file. Here you need the find the installation_coordinator.xml and installation_components.xml files (both within the installer folder of the model architecture in eclipse). Again, more info on Pamela Tomans post.
I have a slight issue with this step however. My installation_coordinator.xml file has a slightly different format to that suggested by Pamela (and others when I googled online). Im still trying to work out where to add the necessary information..... The install_components.xml file was straightforward to amend.

4. Ok, now you should be ready to update the batch_params.xml file. Again, Pamela has a good example on her page. Im currently working through this to get ready to test with a simple one-parameter change and only 5 runs. I'll update once I know more and post my final .xml file.

5. Now comes the tricky bit as far as I can tell. If the batch is to run within repast then you should just be able to choose the batch model run and show it the batch_params.xml file. Again I should be testing this soon.... if the batch is to export and go to a super-computer, then the batch file itself needs to be amended. Not sure where to find this or how to run the batch file outside of repast. Should have some answers here within the month. Fingers crossed.

Useful webpages
Pamela Toman - http://www.pamelatoman.net/blog/tag/batch-runs/
Repast Simphony batch runshttp://repast.sourceforge.net/docs/reference/SIM/Batch%20Runs.html
Repast Simphony batch parametershttp://repast.sourceforge.net/docs/reference/SIM/Batch%20Parameters.html
Repast Parameter Sweeps Getting Startedhttp://repast.sourceforge.net/docs/RepastParameterSweepsGettingStarted.pdf

1.12.11

Some GIS analysis

Ok, so I'm fed up of doing something in GIS, forgetting to write it down and then having to repeat the process due to an update of GIS data, or a change in my model needs etc that I am now trying to make a note of the main GIS analysis to get the data into some format that I can then use in my models, so here goes.

Data I need at the moment:
Habitat Map in raster format, cells of size 100m x 100m
Roads and trails, in raster format, cells of size 100x100
Cockscomb, raster - a simple map of where the protected forest is
CameraTraps - a shape file of the location of all 47 camera traps (in suitable projection to match the raster data
Sample area - a raster dataset of a buffer around the camera traps that represents the sampling area of the traps
Rivers, in raster formation, cells of size 100x100
Model Area, a shape file created to represent the area to be used in the model

Each of these datasets also needs to be of the same area (an annoying problem in some cases)

So, all data was provided in shape file format which meant it all had to be converted or processed and then converted to raster.

All information is relevant to ArcGIS version 9.3. (ArcMap unless otherwise stated).

HabitatMap
1. A simple conversion from 'feature to raster', using Ecosystem field as the field of interest and stating a cell size of 100.
[Conversion Tools - To Raster - Feature To Raster]

2. This raster then covered the entire area of Belize, so it needed to be clipped to meet the model area of interest. (I'll discuss how to create a shape file of the required area next), but otherwise use the 'clip' command. Some commands from the various toolboxes only work on specific types of dataset, such as the clip command within the Analysis Tools toolbox only works with feature/shapefile data and NOT with rasters. For Rasters, use the following, putting the shape file to use as the 'clipping' feature in the 'output extent' box and selecting the 'use input features for clipping geometry box', otherwise you can designate your own coordinates to create a rectangle to use to clip...

 [Data Management Tools - Raster - Raster Processing - Clip]

3. Now we should have a raster of cell size 100x100, but only having data for the required region/area of Belize. This now needs to be converted to an ASCII file for me to use and import into RePast.

[Conversion Tools - From Raster - Raster to ASCII]


Model Area
For this we need to create a new shape file and then amend it to create a new polygon for the area we want to use as our model area.

1. Open Arc Catalog, locate the folder you want the file to be created in.

2. Right click in the main box (showing contents of the folder you are looking at), go to New, and shape file. Then give it an appropriate name.

3. Ok, now go back into ArcMap and add the new shape file to the display.

4. Now you need to edit the shape file
[View (from the top bar) - Toolbars - Editor - Editor - Start Editing]

5. At this point, you may need to select the fold or database which you would like to edit. Select the folder which houses the newly created and added shape file, click OK.

6. Make sure the correct shape file is displayed in the Target box on the Editor Toolbar

7. Now you need to create a polygon of the area you want to be the model area
[Editor -More Editing Tools - Advanced Editing]

8. A new toolbox should have popped up called Advanced Editing. Select the rectangle icon (last but one on the right) and now you should be able to draw a rectangle within the correct shape file layer. You can have other layers open so you can see where to draw the rectangle. If the rectangle is selected it can also be deleted so it doesn't matter if it isn't correct first time. Once you have the area you are happy with, go back to the editor toolbar
[Editor - Save Edits- Stop Editing]

9. There should now be a shape file with a single polygon representing the outline of the model area you want to use. This shape file can now be used to 'clip' any dataset required (as in step 2 above).


Cockscomb
1. Ok, so I was given a dataset with all the protected areas outlined on it, as well as a single dataset with the outline of Cockscomb Basin Wildlife Sanctuary. This simply needed to be clipped to the model area (my model area only covers a portion of the sanctuary) and then converted to a raster and then ask ASCII.
So first, clip the polygon of Cockscomb, and use the newly created ModelArea file (above) as the 'clip features'
[Analysis Tools - Extract - Clip]

2. Now convert it to raster (you could also convert it to a raster first and then use the raster clip function (outlined above) to clip the raster).
[Conversion Tools - To Raster - Feature To Raster]

3. Now convert the raster to an ASCII file
[Conversion Tools - From Raster - Raster To ASCII]


Roads/Trails and Rivers
1. These are both done in the same manner so can be dealt with together. They came in polyline format (shape file) so they need processing and then converting to a raster. Firstly, they needed transforming form they current WGS-1984 projection to the required NAD1927-16N projection (all GPS and camera data information is in the latter format). This is relatively simple. If you have other data open when you add the roads/rivers data it will tell you it is in a different coordinate system and you can change it from that pop-up box, otherwise do the following:
[View (top bar) - Data Frame Properties - Coordinate System]

2. You should now see what coordinate system your current data is in, if it needs to be change:
[Transformations - Select the correct coordinate system in the 'Convert from' box and make sure the correct new coordinate system is in the 'Into' box, now select a transformation technique from the 'Using' box, (they should all do the same job), then press OK - Apply - OK] 
Data should now match.

3. Now the data is in the correct coordinate system, it needs to be processed. I had several different files that needed merging together to create a single file of the entire road/river network. This can be done several ways, but the easiest (and most effective) way I found was via the editor toolbox. I also needed to create some additional trails from point data supplied.

4. Creating new trails, need to create a new shape file layer in Arc Catalog (as above for the Model Area). Add the new empty layer into ArcMap. Display the data of points that represents the information you need. 
[View - Toolbars - Edtor - Editor - Start Editing]

5. Now all you need to do is draw over the points to create a line. The trick is to make lots of joins to make sure the line follows the points. Selecting the pencil icon on the editor toolbar allows you to draw onto the empty shape file layer. A single click make a join and a double click ends the current line. You can connect separate lines together at the end, so I zoomed in and make several lines that I then joined up at the end to create the entire trail network. Once all the lines have been drawn, you can then merge them.

 [Click on the arrow head on the editor toolbar - draw a large square around your newly created lines to select them all - Editor - Merge]

6. Now all the lines should be joined up but still selected. Selection(from top bar) - Clear Selected Features, will clear a selection at any time. Now you need to join the newly created trails with the several existing datasets. A similar process can work successfully, or you can do it via the Data Management Tools 
[Data Management Tools - General - Merge]

7. Now you should have one layer with all the relevant roads or rivers in. Now this needs to be clipped using the Model Area shape file.
[Analysis Tools - Extract - Clip]

8. Again now convert it to a raster and then to an ASCII file.

9. Some problem I encountered - the original roads data was given to me, not of the whole of Belize, but of a small area within the area I was using as my model area. Therefore the dataset was SMALLER than the model area I needed. Problem!

10. Much investigation didn't come up with a good process for extending the display of the dataset (it only needed additional NoData information to make up the entire area). You can extend the display of the layers 
[right-click on the layer - Properties - Extent - choose any layer in the 'set the extent to' drop down box]

11. Whilst this seemed to work when I converted the layer to a raster it lost this additional extent. So do this instead, you need to convert the ModelArea shape file to a raster and then add the two raster layers together:
[ModelArea = Conversion Tools - To Raster - Feature to Raster]
[View(top tool bar) - Toolbars - Spatial Analyst - Options - Extent - Union of Inputs] then
[Spatial Analyst - Raster Calculator - select the new raster of the modelArea then select the + and then select the roads raster file]

12. This should create a raster layer of the roads that same size as the modelArea. The raster layer of the ModelArea needs to have a non-negative, non-zero value (mine went to 1 automatically) so that this value is added to the value of the roads (I have 6 classes of roads all with a value from 1 to 6 representing the class). The values of my new raster went from 2 to 7 so I used the reclass function to put them back to 1 - 6, with the NoData values sticking at -9999. I had some problems converting these values to anything else in the reclass function so I left them at the default value.

[Spatial Analyst Tools - Reclass - Reclassify - choose the new roads raster and enter in the new values in the NewValues column in the box in the centre]

Camera Traps
1. These were fairly straightforward. I had the data as x and y coordinates in an excel spreadsheet. So add the spreadsheet to the ArcMap display:

[right click on the spreadsheet - Display XY Data - and choose the correct columns that represent the x and y data - choose the correct coordinate system, via - Edit - Select - Projected Coordinate Systems - UTM - NAD 1927 - NAD 1927 UTM Zone 16N.prj - Add]

2. You might then need to make the layer permanent, to do this you need to export it as a shape file:

[right-click on the new 'events' - Data - Export Data - then choose All Features in the 'Export' box and the folder you want in the 'Output shape file or feature class' box and give it a name you want - OK]

Sample Area
1. So this is the effective sampling area of my dataset - basically just a circle around each camera Trap of a specified radius - calculated from the average home range of a jaguar - 1784m in this case (half of the full estimated diameter of 3568m - taken from thesis if Rebecca Foster (currently working for Panthera in Belize and collaborating on this work)). So to do this you use the buffer function: 

[Analysis Tools - Proximity - Buffer - new cameraTrap file as the 'Input Features', choose an appropriate name and location for the output file, put the radius in the 'Linear Unit' box and make sure the next box is in the correct units]

2. This now needs to be converted to a raster and made the same size as the modelArea, then converted to an ASCII.

All these files need to be converted to .pgm files (apart from the cameraTraps) for importing into RePast. I'll cover this in a later post.


2.9.11

GRASS GIS

I'm now mainly working on Mac OS so using ArcGIS is becoming a bit of a problem. I have it on my Del laptop, but this is getting a bit slow now and it takes a while to do anything with the big datasets that I need to use of Belize. I also have VMWare on my iMac, but its linked to my university desktop environment, rather than being standalone and so the whole windows experience is quite a painful one.

Roll in - GRASS. An open source GIS package, find more information here.
GRASS works on any platform which makes it appear a good choice. I've yet to test its capabilities but I'll be updating my progress with it in the near future.

To get GRASS working, it requires three frameworks (GDAL Complete, Freetype and Cairo) to be installed prior to installing the GRASS package. Find them, and more info at www.kyngchaos.com/software/grass.


1.9.11

Some useful technical information

If the eclipse.ini file needs editing, (to increase memory or 'Java heap space') this can be found easily by going through the eclipse directory in Windows. In Mac OSX, go to eclipse.app, right-click, open package contents, contents, Mac OS, then open the eclipse.ini file in text edit.

JDK and JRE are needed for model development. The Java Runtime Environment is needed to run the java applications, the Java Development Kit is needed to develop java applications.

Subversion needs to use the SVNKit rather than the JavaHL in eclipse. This is true for Windows and Mac OS.
Subversion also brings problems when trying to save the scenario in repast. The projectName.rs folder and the styles sub folders both need to be un-checked as read-only. I've found this problem with both Windows and MacOS. In Windows, a secondary projectName.rs.bak folder is created if saving the scenario encounters this problem. In this case the subfolders and files need to be moved back into the projectName.rs folder and the projectName.rs.bak folder deleted. This doesn't seem to occur in Mac OS.

JOGL and Java3D jar files can be downloaded and installed directly from the repast homepage; http://repast.sourceforge.net/download-extras.html, again this is true for Windows and Mac OS.
Java3D files allow applications with 3D displays to run.
JOGL is Java OpenGL which is a wrapper that allows OpenGL to be used, necessary for repast models to run successfully.

Python plugin for eclipse - need to also download ActiveTcl (currently version 8.5.10 as of Sept 11) to allow use of TKinter.

GeoTools seems to be a set of java open source code library classes which provide standard compliant methods for manipulation of geospatial data. Should allow use of raster files, without converting to .pgm files. Currently testing this as of Sept 11.
There is a website dedicated to the open source files - http://geotools.org/
My current version of eclipse seems to have access to these class files without the need to download anything extra. The geoTools website seems to indicate you need to download and install the GeoTools code into both eclipse and netBeans. Will update when I know more.

24.8.11

Demo models for repast

After struggling to remember how to get access to the repast demo models, which are EXTREMELY helpful when trying to figure out how repast works, they can be downloaded from http://repast.sourceforge.net/models.zip

After extracting the files, get the models into Eclipse easily by:
1. Select File -> Import Repast Examples from the Eclipse main menu
2. Check Select root directory: /home/rlr/Repast/Repast-Models/models (not: Select archive file)
3. Check the boxes for the example projects you would like to import select all copy projects into workspace
4. Click Finish
Now they all appear in the packages panel

On a Mac eveything should work fine, if working on Windows there may now be problems running some of the example models due to JOGL and Java3D errors.

Meghan Hutchins provides an excellent outline of how to fix these errors, please see the link on the left to her blog, or else click here for the specfici pages related to demo models and how to fix errors that may occur. (User guide to Eclipse/Repast)
http://meghanhutchins.com/pmwiki.php/Main/InstallJava3DLibraries

19.7.11

Eclipse plugins and configurations

Ok, so now I've moved on from netlogo, the decision of which interface and language to use is a pretty big one. After some considerable time looking into the pros and cons of different languages I settled on java, with its flexible use and wealth of support information available.

I trialled NetBeans for a while which I quite liked, but then settled on Eclipse after some recommendations from friends. The brilliant thing with Eclipse is also that i can use it for more or less EVERYTHING! Via plugins, I now use it as my base for java, python and LaTeX, linking it up to my university server repository via the subclipse plugin.

Some details on setting up plugins is as follows (all configured for the most recent Eclipse Indigo):

For LaTeX:
Texclipse - found at http://texlipse.sourceforge.net
In eclipse, go to Help > Install New Software > type the above URL in the  'work with' box and press 'Enter'
select the texlipse box and press next until the process is finished.

For Version Control
Subclipse - found at http://subclipse.tigris.org/update_1.6.x (this is the version for Eclipse Helios. There is currently no updated version for Indigo)

Again, go to Install New Software and enter the URL above.

After installing this there are several things to note. Using a windows machine, I had problems using the JavaHL interface, so I recommend using the SVNKit bundle instead (go to Windows > preferences > team > SVN > SVN interface - choose SVNKit.)

In order to checkout a project from an online repository:
go to the required perspective, right click > import > SVN > checkout from SVN > put the repository location in the URL, for me this was svn+ssh://username@svn.forge.ecs.soton.ac.uk/folder/repositoryProjectName

You dont seem to need the Tortoise SVN programme that is recommended for Windows machines if you use the subclipse plugin.

For Python
Pydev - found at http://pydev.org/updates

Install new Software > enter in URL > select Pydev (NOT PyDev Mylyn Integration)
> click next to finish.
A box should pop up asking you to trust the certificates, YOU NEED TO SELECT THE Antana PyDev; Pydev; Aptana CHOICE, OTHERWISE PYDEV WILL NOT INSTALL
You then need to restart Eclipse

Pydev then needs configuring - you need python already installed on your computer
Windows > preferences > pydev > interpreter Python > new > then browse to the current version of Python.exe > ok > select all of the options EXCEPT PySrc and python.zip > then ok as many times as needed to end the process

All of the information on the PyDev plugin and more can be found on:
www.rose-human.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm

For Repast Simphony
You need three separate installations for this plugin
1. Groovy-Eclipse
found at http://dist.springsource.org/release/GRECLIPSE/e3.7/ (3.7 refers to the version for Indigo, older version of eclipse will need the relevant version of groovy)
2. Web, XML & Java EE development
found at http://download.eclipse.org/releases/indigo (again you need the relevant site for the eclipse version you have)
under the Eclipse XML editors and Tools menu
3. Repast
found at http://mirror.anl.gov/pub/repastsimphony/2.0.0.beta

there are a LOT of example models available within the repast plugin that show a great range of things that repast can do.

I'm currently trying to work my way around repast, I hope to have more on this at a later date.