Skip to content

selection of data subsets in spatial classes

2 messages · karl.sommer at dpi.vic.gov.au, Roger Bivand

#
after some fiddling with the GridTopology() method I eventually succeeded
in making it work and now can interpolate onto the grid.

Tremendous, thanks.

One problem I encountered when specifying a number smaller than 1 for the
cellsize argument eg. c(0.5, 0.5) instead of c(1,1),  I get erroneous
results.

grd <- GridTopology(c(617400, 6190060), c(1,1), c(400, 300))

Cheers
Karl



|---------+---------------------------->
|         |           Roger.Bivand at nhh.|
|         |           no               |
|         |                            |
|         |           08/06/2006 18:53 |
|         |           Please respond to|
|         |           Roger.Bivand     |
|         |                            |
|---------+---------------------------->
  >------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                              |
  |       To:       karl.sommer at dpi.vic.gov.au                                                                                   |
  |       cc:       r-sig-geo at stat.math.ethz.ch                                                                                  |
  |       Subject:  Re: [R-sig-Geo]  selection of data subsets in spatial classes                                                |
  >------------------------------------------------------------------------------------------------------------------------------|
On Thu, 8 Jun 2006 karl.sommer at dpi.vic.gov.au wrote:

            
than
My immediate guess would be that the overlay method will get you there:

library(sp)
plot(1:100, 1:100, type="n")
poly <- locator()
poly <- do.call("cbind", poly)
poly <- rbind(poly, poly[1,])
lines(poly)
field <- SpatialPolygons(list(Polygons(list(Polygon(poly)), ID="field")))
grd <- GridTopology(c(0.5,0.5), c(1,1), c(100, 100))
SG <- SpatialGrid(grd)
plot(SG, add=TRUE)
t1 <- overlay(SG, field)
SGDF <- SpatialGridDataFrame(grd, data=AttributeList(list(field=t1)))
SPDF <- as(SGDF, "SpatialPixelsDataFrame")
plot(SPDF, col="red", add=TRUE)

and then use the SPDF points for prediction. If you've read in the field
polygon, you're already mostly set up. It will also work with multiple
fields, when t1 will know which field the grid point belongs to.

Using GridTopology to set up prediction grids is quite neat too, it
provides an object to encapsulate what you are doing, but ensures that you
register the grid to the grid centres.

Hope this helps,

Roger
FALSE)
col.regions=bpy.colors(64))
------------------------------------------------------------------------------------------------------------------------------|
|
|
|
classes                                                |
------------------------------------------------------------------------------------------------------------------------------|
of
have
screened
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
#
On Fri, 9 Jun 2006 karl.sommer at dpi.vic.gov.au wrote:

            
Good
I think this is a matter of screen representation:

coordinates(GridTopology(c(617400, 6190060), c(0.5,0.5), c(4, 3)))

looks wrong, but

print(coordinates(GridTopology(c(617400, 6190060), c(0.5,0.5), c(4, 3))), 
  digits=10)

shows that the coordinate values were been rounded for display (is that 
what you are seeing?)

Roger