An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121216/28a02b3b/attachment.pl>
looping through spatial points and getting counts of spatial points in spatial grid in R
2 messages · Tilottama Ghosh, John Kane
Sample data? Please supply some sample data and code. The easiest way to supply data is to use the dput() function. Example with your file named "testfile": dput(testfile) Then copy the output and paste into your email. For large data sets, you can just supply a representative sample. Usually, dput(head(testfile, 100)) will be sufficient. John Kane Kingston ON Canada
-----Original Message-----
From: waggymaggy at yahoo.com
Sent: Sun, 16 Dec 2012 23:07:54 -0800 (PST)
To: r-help at r-project.org
Subject: [R] looping through spatial points and getting counts of spatial
points in spatial grid in R
Hi,
I am stuck in a looping problem. It might be an easy problem for
experienced R users but I have been unable to do it. Any kind of help or
advice will be great appreciated.
I am creating a spatial grid and have a list of spatial points in a
folder. I can read the spatial points separately and get a count of the
points in the spatial grid in R. The output should be a table showing the
counts of points in the spatial grid. However, since there are many of
these spatial points, I want this process to be automated. Can someone
help me with this? All my spatial points are in one folder.
# Creating spatial points in R - reading the POI shapefiles as
SpatialPointsDataFrame in R autopts.rg <- readOGR(".", "AutoSvc")class
(autopts.rg)
# Getting a count of the Spatial Points in the Spatial Data Frame in.cell
<- overlay(SpatialGrid_LS,FinInstq2) newdata <-
data.frame(table(in.cell))View(newdata)
"SpatialGrid_LS" is the spatial grid that I had created in R.
I guess a For loop would help, but although I tried several things, I
haven't been successful yet.
Thanks!
Tilo
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________ GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails