Finally, I've given up
using distmap on an object imported
from a shp file. Could not solve the casting
problem from the sp object to the owin object.

I've rasterized the vector prior to importing to R
and this is the way I calculate the distmap and export it.

refG25 <- readGDAL("GFOEOABUFActi25.tif")
a <- as.image.SpatialGridDataFrame(refG25) #here proj info is lost
ai <- as.im(a)
ai$v[ai$v==0]<-NA #0 values in the raster are the background
adist <- distmap(as.owin(ai))
adistlog <- adist
adistlog$v <- log(adistlog$v+1) #log transform

#Export works but Global Mapper claims there is no Datum
#TNT claims there is no Gereferenciation at all (not true!)
adistlogim <- as.SpatialGridDataFrame.im(adistlog)
[EMAIL PROTECTED] <- [EMAIL PROTECTED] #Recover proj info
writeGDAL(adistlogim, "GFODISTLOG.tif", drivername = "GTiff", type = 
"Float32", mvFlag = NA, options=NULL)

#Another alternative, same result: Datum is lost
GFODISTLOG <- refG25
[EMAIL PROTECTED] <- [EMAIL PROTECTED]
writeGDAL(GFODISTLOG, "GFODISTLOG.tif", drivername = "GTiff", type = 
"Float32", mvFlag = NA, options=NULL)

Hope this helps somebody else. Please let me know if you think of
a better way.

Agus
-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to