Skip to content
Back to formatted view

Raw Message

Message-ID: <1430485336885-7588149.post@n2.nabble.com>
Date: 2015-05-01T13:02:16Z
From: sadaoui
Subject: Delimit a polygon for the region which is> 1000 m from my raster altitude
In-Reply-To: <D1680198.12746D%macqueen1@llnl.gov>

Thank you very much "MacQueen, Don"  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 contour

x <- rasterToContour(r,levels=500)
class(x)
plot(r)
plot(x, add=TRUE)

#export contour to shapefile

library(rgdal)

writeOGR(x, ".", "contour", driver="ESRI Shapefile")


but when I open the shapefile, is a  lines not a polygons? My goal is to
have the polygon areas for altitude> 500m.

I thought to "rasterToPolygons"

library(raster)
library(sp)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)

# add polygon

library(rgeos)

pol <- rasterToPolygons(r, fun=function(x){x>500})

plot(pol, add=T, col='red')

#export polygon to shapefile

library(rgdal)

writeOGR(pol, ".", "polygon", driver="ESRI Shapefile")



but the result, it displays a shapefile with polygons for each pixel

I just want  a polygons to areas where are> 500m, not for each pixel.

Thank you again 







--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Delimit-a-polygon-for-the-region-which-is-1000-m-from-my-raster-altitude-tp7588147p7588149.html
Sent from the R-sig-geo mailing list archive at Nabble.com.