Dear R colleagues,
Currently, I am working with the vegetation map published by SAGE
(http://www.sage.wisc.edu/download/potveg/global_potveg.html). This map is
published in netcdf and I can easily load it into R using the package "raster".
But I have found another vegetation map (also netcdf, same resolution) which
is more realistic to my work region. Thus, what I need to do is overlay the two
maps, but using a clip feature (i.e. a shapefile of South America) as a
delimiter to this operation, in order to capture the information of the newest
map.
I am trying to use the "overlay" function of raster package, but apparently
it isn't possible (or I am missing something) to use a clip feature to restrain
the spatial domain of the operation.
Any tips on how to do this? Below is the code I am using.
Best wishes,
Thiago Veloso.
#Loading required packages
library(raster)
library(maptools)
#Loading SAGE vegetation map
vegmap<-raster("C:/temp/vegmap_ibis/data/vegtype.nc")
#Loading new vegetation map
new_vegmap<-raster("C:/temp/vegmap_ibis/data/new_vegtype.nc")
#Loading SA shapefile
south_america<-readShapePoly("C:/temp/vegmap_ibis/shapes/southamerica.shp")
#Replacing the original map with the modified one
result<-overlay(vegmap,new_vegmap,fun=function(x){x}) #this is where I stop - I
don't know how to use the shapefile as a clip feature in this function...
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo