Just how does this all fit together

321 views
Skip to first unread message

Wayne Hajas

unread,
Jun 1, 2012, 2:53:08 PM6/1/12
to Maxent
This is a question about Maximum Entropy in general and not about the
MAXENT software. My apologies if this is the wrong place for my
question.

I have some presence-only data and I think Maximum Entropy might be a
useful tool for identifying other locations where the animal exists.

I have been going through references such as Phillips et al 2006 and I
am just not sure I understand how the whole thing fits together for an
unconditional Maxent Model. How do we actually make a prediction for
the test-data? I will express how I think things work and then
hopefully somebody will tell me where I am wrong.

1. I identify locations where my creature is known to exist.

2. For those locations I assemble an environmental dataset.

3. Based upon this environmental data, I estimate lambda-values and a
probability for each training-location.

4. I choose a test-location(s) where I don't know if my creature
exists and assemble an environmental dataset.

5. I use the lambda's and the test environmental-data to estimate a
probability. If the test-probability is low relative to the training-
probabilities, then my creature probably dosen't live there.

So do I have it basically right? Or am I really out to lunch?

Thanks for your attention,
Wayne Hajas

Colin Driscoll

unread,
Jun 2, 2012, 5:15:03 PM6/2/12
to max...@googlegroups.com
Wayne, these two papers might help

Williams, J.N., Seo, C., Thorne, J., Nelson, J.K., Erwin, S., O’Brien, J.M. & Schwartz, M.W. (2009) Using species distribution models to predict new occurrences for rare plants. Diversity and Distributions, 15, 565-576.
 
Siqueira, M.F. de, Durigan, G., Marco Júnior, P. de & Peterson, A.T. (2009) Something from nothing: Using landscape similarity and ecological niche modeling to find rare plant species. Journal for Nature Conservation, 17, 25-32.
Cheers
 
Colin
 

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/maxent?hl=en.


Raes, N. (Niels)

unread,
Jun 4, 2012, 5:13:19 AM6/4/12
to max...@googlegroups.com
Dear list,
 
I am working on the distribution of species in the swamp forests of the island of Borneo. I do have quite a large number of collections that were found on, or very close to the coast. Since I am using the 5 arcmin resolution worldclim data, many of my collection fall just  outside the grid cells. Has anyone developed a script (in R?) that automatically moves these collections to the nearest grid cell, given that the distance between a collection site and a (centre?) grid cell is no more than 2 grid cells ?
 
Best,
 
Niels

Marwa Waseem

unread,
Jun 4, 2012, 1:09:40 PM6/4/12
to max...@googlegroups.com, niel...@gmail.com
Niels,,
you may need to interpolate your raster so that your points fall on grid cells with values. You could use the focal statistics in ArGIS (use Map Algebra tool for that) to do this using a certain kernel size, in the simple code below I am using a kernel of size 25x25, you might need to change this.
Con(IsNull("InRas"),FocalStatistics("InRas",NbrRectangle(25,25),"MEAN"),"InRas")
I hope this helps

Marwa Waseem



From: "Raes, N. (Niels)" <niel...@gmail.com>
To: max...@googlegroups.com
Sent: Monday, June 4, 2012 2:13 AM
Subject: Moving coastal collections to the nearest grid cell

Elizabeth J. Sbrocco

unread,
Jun 4, 2012, 1:30:43 PM6/4/12
to max...@googlegroups.com
I've only ever done this manually, so I would be really interested if someone has a script they can share for doing it automatically!

Heroen Verbruggen

unread,
Jun 6, 2012, 2:18:28 AM6/6/12
to max...@googlegroups.com, Niels Raes, ladybl...@gmail.com
Niels, Elizabeth,

I have written a tiny Java program that automates this. It is part of the RasterTools package and is available here: http://phycoweb.net/software/software.html.

It didn't have the option to work with a distance threshold as Niels suggested, but since that is a very useful function I have implemented that functionality in the latest version. For more details on the new version, see http://phycoweb.wordpress.com/

I hope this is useful and welcome your suggestions.

Cheers,
Heroen

John B

unread,
Jun 6, 2012, 10:47:21 PM6/6/12
to max...@googlegroups.com
Hi all,

I bashed something out to do this with R. Find the R function attached, as well as a dummy raster and occurrence csv. 

Run the source code, then use the function as follows:

# set your working directory
new_occ <- move.points(rast='dummy_raster.asc', pts='dummy_occ.csv', tol=2, outfile='new_points.csv')
head(new_occ)

The arguments to the move.points function are:
rast: the path to one of your enviro grids (supports .asc... haven't tested others)
pts: your occurrence csv file
xy: a vector of column indices that contain lon and lat, respectively (typically c(2, 3) if in Maxent format, and this is the default)
tol: your tolerance, i.e. the distance that a point is allowed to be from the center of an edge-cell of your raster, in multiples of your grid  resolution. For example, if your resolution is 0.0025 and tol=2, then all points that fall within 0.005 of the center of an edge-cell of your grid will be moved to the closest edge cell. Note that this is different to expanding the entire grid by 2 cells.
outfile: the path to the new csv file you'd like to contain the output (existing files with this path will be overwritten)
diagnostic: produces a plot indicating which points have been moved (example pasted below, where the rectangle indicates your raster extent). Default is TRUE. Set to FALSE to disable. 

The output will be written to the outfile, and will also be returned as the object that the function's returned value is assigned to (e.g. new_occ, in the example above).

Can't guarantee it's bug free... let me know if it's not working for you.

Cheers,
John



On Tuesday, 5 June 2012 03:30:43 UTC+10, Elizabeth Jones Sbrocco wrote:
I've only ever done this manually, so I would be really interested if someone has a script they can share for doing it automatically!
On Jun 4, 2012, at 5:13 AM, Raes, N. (Niels) wrote:

Dear list,
 
I am working on the distribution of species in the swamp forests of the island of Borneo. I do have quite a large number of collections that were found on, or very close to the coast. Since I am using the 5 arcmin resolution worldclim data, many of my collection fall just  outside the grid cells. Has anyone developed a script (in R?) that automatically moves these collections to the nearest grid cell, given that the distance between a collection site and a (centre?) grid cell is no more than 2 grid cells ?
 
Best,
 
Niels

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+unsubscribe@googlegroups.com.
dummy_occ.csv
dummy_raster.asc
movePoints.R

John Baumgartner

unread,
Jun 24, 2012, 6:13:19 PM6/24/12
to max...@googlegroups.com
Hi Charlotte,

You first need to run the code in the file movePoints.R that I provided. You can do this by copying and pasting all lines into R and running, or by using the source() function, I.e. 

source("c:/path/to/movePoints.R")

(substitute in the actual path to where you've downloaded the file).

Should work after that.

Cheers,
John

On 25/06/2012, at 6:48 AM, Charlotte <cger...@ufl.edu> wrote:

Hello, 

Thank you for this useful tool, John. However, when I run your dummy datasets, I get this error: 

new_occ <- move.points(rast='dummy_raster.asc', pts='dummy_occ.csv', tol=2, outfile='new_points.csv')

Error: could not find function "move.points"

> head(new_occ)

Error in head(new_occ) : object 'new_occ' not found


Do you have any idea what is going on ? I am very interested in running this for my own dataset (very large, do doing this manually is just not an option). 

Thank you ! 

Charlotte

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/GqnttaLZNQQJ.

To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.

John Baumgartner

unread,
Jun 24, 2012, 6:29:30 PM6/24/12
to max...@googlegroups.com
(this makes the movePoints function available for use)

Raes, N. (Niels)

unread,
Jul 4, 2012, 3:02:09 AM7/4/12
to max...@googlegroups.com
Thanks John!
To view this discussion on the web visit https://groups.google.com/d/msg/maxent/-/7MFqTn40wgwJ.

To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.

Dale Forrister

unread,
Apr 16, 2014, 2:50:32 AM4/16/14
to max...@googlegroups.com
Elizabeth or anyone else who may be able to help,


How do you do this manually?

I only have a few points to move to the nearest grid cell. I've attempted to get some of these solutions to work but they are over my head. How can one simply move occurrence points so they fit within raster data, or extract the raster data from the nearest grid cell and apply these to points just outside of the raster data.

Thank you kindly,

Dale

Martin Damus

unread,
Apr 16, 2014, 7:05:53 AM4/16/14
to max...@googlegroups.com
Hi,

Load your presence locations on a GIS (DIVA-GIS works fine for this and is free) along with one environmental layer at the desired resolution -- zoom in on the coastal area and you will be able to see which points lie outside your raster's data range and choose the grid cell you want to move them to -- which you then just do in Excel or Notepad, or whatever, by changing that presence point's lat-long coordinate manually. Very tedious if you have more than a few to do.

When you run Maxent, you may still get the 'missing data' alert -- that is likely because some environmental layers have different coastal outlines. Take note of which layer has missing data and correct for that one.

Cheers,
Martin

From: Dale Forrister <dlfor...@gmail.com>
To: max...@googlegroups.com
Sent: Wednesday, April 16, 2014 2:50:32 AM
Subject: Re: Moving coastal collections to the nearest grid cell

To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.

To post to this group, send email to max...@googlegroups.com.
Visit this group at http://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.


Elizabeth J. Sbrocco

unread,
Aug 8, 2014, 3:00:02 PM8/8/14
to max...@googlegroups.com
Hi Dale,

If you have ArcGIS, I have recently discovered a rather easy way to "move" points to the nearest grid cell.  First off, take any of your environmental layers and create a raster grid in ArcGIS using the ASCII to raster tool (or another conversion tool, depending on the file format of your environmental data).  Next, convert this grid to points using the convert raster to points tool.  This will give you a set of points that sit on the exact center of each of your grid cells - I will call this your "grid points" layer.  Finally, use the "Near" tool in the Proximity toolset within the Analysis toolbox to determine the XY location of the closest grid point to each of your occurrence points.  Within the tool, select your shapefile or feature class containing your occurrence records as your "in_features."  Select your grid points layer as your "near_features."  Select the optional "location" checkbox in order to save the XY coordinates and not just the FID of the near feature to your output.  You can set a search radius if you'd like, but I usually don't.  The program will return a "near_distance" field that will allow you to make decisions about distance thresholds later (I personally don't like to keep occurrence points that are greater than a pixel or two away from my raster grid).

The near_distance and XY coordinates of the nearest point in your "grid points" layer will automatically be saved as new fields in your occurrence shapefile/feature class layer.  You can export the entire dataset to a comma-delimited text file and re-format it for use with MAXENT.  Note that this method also moves the location of points that DO fall within a grid cell to the center of the cell they fall in.  Using the original XY location or the cell center  for these points shouldn't make a difference in your analysis.  Here is a link to the ESRI help page for the near tool: http://resources.arcgis.com/en/help/main/10.2/index.html#//00080000001q000000

Hope this helps (and sorry it took me 4 months to post a reply!).

~Elizabeth Sbrocco

Elizabeth J. Sbrocco

unread,
Aug 8, 2014, 3:04:17 PM8/8/14
to max...@googlegroups.com
I just wanted to add a minor clarification -- this method doesn't actually "move" occurrence points that are stored within a shapefile/feature class -- but it records the XY coordinates of the nearest cell center within your analysis mask, which you can then use as the occurrence point's new location in MAXENT.

Cheers,
Elizabeth

John Baumgartner

unread,
Nov 1, 2014, 7:07:42 AM11/1/14
to max...@googlegroups.com
For future reference, I've posted to StackOverflow a pretty efficient R method for moving points that fall outside a raster's extent to the nearest raster cell. (This particular implementation doesn't allow specification of a maximum distance - all points outside the raster are moved to the nearest raster cell.)
Reply all
Reply to author
Forward
0 new messages