Ok thank you Robert Hijmans
If you want to keep the raster cell values, you could do
shapefile(pol2, polygon2.shp)
and use that file.
On Sat, May 2, 2015 at 2:10 PM, sadaoui lt;sadaouimahrez@gt; wrote:
Thank you Robert Hijmans,
it works with this function ;
shapefile(pol3,
You can try fiddling a bit with:
pol2 - rasterToPolygons(r, fun=function(x){x6}, dissolve = TRUE)
pol3 - gBuffer(pol2,width=1e-5, byid=FALSE)
Where the width is sufficiently small as to not affect the general shape.
However, it yields very jagged polygons, which I do not know if it is what you
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){x500}, dissolve
Thank you Robert Hijmans,
it works with this function ;
shapefile(pol3, polygon3.shp)
but I want to have the corresponding data to this shapefile.
I tried, as did you say :
or use the SpatialPolygons object to create a SpatialPolygonsDataFrame
and then use writeOGR (that is what the
If you want to keep the raster cell values, you could do
shapefile(pol2, polygon2.shp)
and use that file.
On Sat, May 2, 2015 at 2:10 PM, sadaoui sadaouimah...@outlook.com wrote:
Thank you Robert Hijmans,
it works with this function ;
shapefile(pol3, polygon3.shp)
but I want to have
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
Look into the help page for the contour function in the raster package
It refers to
RasterToContour
Follow the example given in ?RasterToContour
(copied here)
f - system.file(external/test.grd, package=raster)
r - raster(f)
x - rasterToContour(r, levels=500)
class(x)
plot(r)
plot(x, add=TRUE)