[R-sig-Geo] Delimit a polygon for the region which is>, 1000 m from my raster altitude
sadaoui
sadaouimahrez at outlook.com
Sat May 2 21:16:47 CEST 2015
Thank you very much "José M. Blanco Moreno" for your answer.
I have followed your instructions from this script :
library(raster)
library(sp)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
# add polygon
library(rgeos)
pol2 <- rasterToPolygons(r, fun=function(x){x>500}, dissolve = TRUE)
pol3 <- gBuffer(pol2,width=0, byid=FALSE)
plot(r)
plot(pol3,add=TRUE,border='blue',lwd=2,col="red",axes=TRUE)
title("area > 500m")
I have had the result as I want a polygon for the area> 500m.
But,
I found a problem to export this polygon (pol3)
#export polygon to shapefile
library(rgdal)
writeOGR(pol3, ".", "polygon3", driver="ESRI Shapefile")
Error in writeOGR(pol3, ".", "polygon3", driver = "ESRI Shapefile") :
obj must be a SpatialPointsDataFrame, SpatialLinesDataFrame or
SpatialPolygonsDataFrame
it has not recognized as a polygon!!! I don't know why?
thank you for helping me to the last key
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Re-Delimit-a-polygon-for-the-region-which-is-1000-m-from-my-raster-altitude-tp7588152p7588153.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list