[R-sig-Geo] SGDF with NA values - SGDF2PCT()
Häring, Tim (LWF)
Tim.Haering at lwf.bayern.de
Wed Dec 15 15:46:57 CET 2010
Thank you Michael, your workaround gave me the right hint.
Even though your example didn`t work for me I solved the problem.
# first, I create a colour vector, where dist is a data.frame with red, green, and blue values.
cols <- rgb(dist[,1],dist[,2], dist[,3],alpha=.7)
ind <- data.frame(cols=unique(cols), ix=c(1:length(unique(cols))))
# create a df with coordinate values
pd <- data.frame(x = p$RW, y = p$HW, cols)
# add color-index values to df
pd <- merge(pd, ind, by.x="cols", by.y="cols", all.x=TRUE)
# geoformat
gridded(pd) = ~x+y
pd <- as(pd, "SpatialGridDataFrame")
### plot
g <- grey(0:250/250)
image(hillshade, col=g, axes = TRUE)
image(pd, "ix", col=ind$cols, add=TRUE)
Thanks again.
TIM
--------------------------------------------
Tim Häring
Bavarian State Institute of Forestry
Department of Forest Ecology
Hans-Carl-von-Carlowitz-Platz 1
D-85354 Freising
More information about the R-sig-Geo
mailing list