Adam,

Assuming your data are in a data.frame 'd'

library(raster)
r <- raster()
res(r) <- 1/120
cellID <- cellFromXY(r, d[, c('lon', 'Lat')] )

Robert


On Wed, Feb 1, 2012 at 9:13 PM, ADAM PETER CARDILINI <apcar@deakin.edu.au>wrote:

> G'day All,
>
>
>
> I have been struggling to figure out an answer to this question and wasn't
> sure where else to ask, so here goes. I have a large amount of
> presence/absence point data (~125,000) with lon/lat coordinates. Like this:
>
> Lat                          lon                          abs/pres
>      date
>
> 113.6481              -24.90278             0
>  1/1/1998
>
> 113.6481              -24.90278             1
>  1/2/1998
>
> 113.6481              -24.90278             0
>  1/3/1998
>
> 137.5175              -35.69556             1
>  1/1/1998
>
> 137.5175              -35.69556             1
>  1/2/1998
>
> 137.5175              -35.69556             1
>  1/3/1998
>
>
>
> I have been trying to work out a way to identify the cells that each point
> would fall into if it were mapped onto a raster grid (I am using rasters
> with the same cell resolution as BIOCLIM rasters). That is, for all points
> falling within the same cell, I would like to identify them as being a part
> of the same cell. I am trying to model site occupancy for this species from
> repeated survey data, using the package 'unmarked', which requires records
> to be associated with sites. I don't have site IDs with this data so I need
> to come up with a proxy for this. I thought I could use grid cell id as a
> proxy for site id, so that all records that fall within the same grid cell
> can be considered the same site.
>
> How do I identify the grid cell that each point falls into on a raster
> grid and associate it with my presence/absence data, to produce a dataset
> that looks like this?
>
> Lat                          lon                          abs/pres
>      date                       cellID
>
> 113.6481              -24.90278             0
>  1/1/1998              234
>
> 113.6481              -24.90278             1
>  1/2/1998              234
>
> 113.6481              -24.90278             0
>  1/3/1998              234
>
> 137.5175              -35.69556             1
>  1/1/1998              250
>
> 137.5175              -35.69556             1
>  1/2/1998              250
>
> 137.5175              -35.69556             1
>  1/3/1998              250
>
>
>
> Thanks for your help in advance.
>
>
>
> Kind regards,
>
> Adam Cardilini
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

