Hello !

I`m looking for a way to convert a grid with nominal values into polygons. Up 
to now I didn`t find a way to do this in R. Maybe someone can give me a hint.

Here is what I did:

# I start with a xyz table with the coordinates and a factor variable as 
z-value.
# The points were regularly spaced because they were converted from a grid to 
apply a statistical model in R
str(dat)
'data.frame':   337842 obs. of  3 variables:
 $ soil_unit: Factor w/ 37 levels "12b","16b","3c",..: 1 1 1 2 2 2 2 2 2 2 ...
 $ X        : num  4400098 4395378 4400358 4399438 4399638 ...
 $ Y        : num  5578198 5563698 5578238 5564918 5565358 ...

gridded(dat) = ~X+Y  # to get a SpatialPixelsDataFrame

# the following I found on this list to convert 
# grid objects to spatial polygon objects
# see: http://www.mail-archive.com/[email protected]/msg06549.html

dat <- as(dat, "SpatialPixels")
dat <- as(dat, "SpatialPolygons")

The problem is, that every SpatialPixel is converted to one polygon - in my 
case 337842 polygons.
Isn`t there a way to convert a SpatialGridDataFrame or a SpatialPixelsDataFrame 
into a SpatialPolygonsDataFrame. Because I have nominal values the conversion 
has to consider the DateFrame, I think.
But something like
poly <- SpatialPolygonsDataFrame(dat, ...)
gives an error message.

Any help is very welcome.

Thanks
TIM


-----------------------------------------------------------------------------------
 
Tim Häring
Bavarian State Institute of Forest Research 
Department of Forest Ecology
Hans-Carl-von-Carlowitz-Platz 1
D-85354 Freising

E-Mail: [email protected]
http://www.lwf.bayern.de

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to