Skip to content

Questions about spatial data

5 messages · Ronaldo Reis Jr., Andy Bunn, Barry Rowlingson +1 more

#
Hi,

I have two questions about spatial data.

1) I have this grid

x <- rep(c(1:8),c(rep(6,8)))
y <- rep(c(1:6),8)

I need to make some others grids with same length and different numbers of 
points whit a random spatial pattern.

How is the best method to make this in R.

2) I need to produce some grids with the same numbers of points in different 
degrees of aggregation, the level of aggregation for all grids must be 
statistically different.

How to do these grids in R and how to test the significance between these 
grids?

Thanks for all
Ronaldo
#
See the splancs library and the functions

gridpts 
pcp.sim 
csr

in particular. However, what you want to do is not completely trivial.
#
Ronaldo Reis Jr. wrote:

            
This is a bit imprecise. What do you mean by 'same length and 
different numbers of points'?

  Your grid above has 8*6 = 42 points. Do you want to generate a random 
subset of these grid points, selecting each point with a fixed 
probability, or selecting exactly N points?

  Firstly, I would make your grid above using 'expand.grid':

fullGrid <- expand.grid(1:8,1:6)
plot(fullGrid)

  Then you can use the sample() function to choose 10 different integers 
from 1 to 42, and use that to choose rows of the fullGrid data frame:

thinGrid <- fullGrid[sample(42,10),]
plot(thinGrid)

  This gives you exactly 10 points.

  Or you could choose each point with some probability, using runif(42) 
to generate uniform random numbers and compare this with a threshold:

thin2 <- fullGrid[runif(42)>.8,]
plot(thin2)

  This gives grids with differing numbers of points, but each of the 42 
points has a 0.2 probability of being included.
I think at this point you need to find a good textbook on spatial 
point processes, then come back and look at R packages spatstat and to a 
lesser extent, splancs.

  Hope this helps,

Baz
#
That was a subtle Hitchhikers Guide To The Galaxy reference there, 
honest,  and not a stupid dumb multiplication mistake on my part after 
working four 18-hour days on the trot...

  I will now write out 1000 times, 6 times 8 is 48, seven eights are 
fifty-six, eight eights are.. oh hang on I've run out of fingers...

Barry
#
Barry Rowlingson <B.Rowlingson at lancaster.ac.uk> writes:
Maybe that's why we got a letter from "Ford Prefect" today? 

Don't panic, just throw yourself at the ground and miss...