Hi,



Well, After reading the Raster Package document and other book, I have
tried number of things mentioned below:



*Details of the Data I am using:*

-       Raster (Landscan Population Data: 13MM Cells)

-       Vector (Point Data: Restaurants (22428 Points)

[image: https://mail.google.com/mail/ca/u/1/images/cleardot.gif]

*Code that I am trying:*

library(raster)

r <- raster("landscan.tif")

s <- shapefile("Restaurants.shp")



*rr <- rasterize(s, r, fun=function(x,...)length(x)) //* This is the
function written in raster pdf to calculate the sum but I am not sure. How
to implement the same in my case, So, I tried the below mentioned line*//*

* *

rr <- rasterize(s,r,fun=sum)  //* To calculate the total sum of
POIs(Restaurants) lying inside a GRID polygon (Raster:Landscan.tif)*//



names(rr) <- 'count'

p <- rasterToPoints(rr)

cells <- cellFromXY(rr, p[, 1:2])

result <- cbind(cell=cells, p, value=r[cells] )



Please let me know, where I am wrong as I can’t get the sum of POI’s lying
inside a raster cell using the above mentioned code.

-

Priyanka Sharma






On Mon, Sep 10, 2012 at 3:02 PM, Barry Rowlingson <
b.rowlingson@lancaster.ac.uk> wrote:

> On Mon, Sep 10, 2012 at 9:33 AM, Priyanka Sharma
> <priyanka.toxic00@gmail.com> wrote:
> > Hi everyone,
> >
> > Here is a summary of what I am trying to do. Please take a look and let
> me
> > know how can i complete this below mentioned objective using R for a
> large
> > dataset.
> > **
>
>  What have you tried? What level of R knowledge do you have? Do we
> have to tell you how to read a shapefile? Or can we just say "check
> out the raster package, the functions are right there"?
>
> Barry
>

	[[alternative HTML version deleted]]

