Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > tp_fsyl
- class : SpatialPolygonsDataFrame
- features : 149
- extent : -6.776647, 35.13454, 37.74027, 59.70762 (xmin, xmax, ymin, ymax)
- coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
- variables : 3
- names : Id, layer.1, layer.2
- min values : 0, 47.1897926634769, 510.438502673797
- max values : 0, 138.237654320988, 1339.66159594342
- t_fsyl <- fortify(tp_fsyl, region="layer.1")
- > head(t_fsyl)
- long lat order hole piece group id
- 1 17.03176 45.09981 1 FALSE 1 100.269953051643.1 100.269953051643
- 2 17.08139 45.06541 2 FALSE 1 100.269953051643.1 100.269953051643
- 3 17.10079 45.04859 3 FALSE 1 100.269953051643.1 100.269953051643
- 4 17.12986 45.02336 4 FALSE 1 100.269953051643.1 100.269953051643
- 5 17.11578 45.00132 5 FALSE 1 100.269953051643.1 100.269953051643
- 6 17.06936 44.98166 6 FALSE 1 100.269953051643.1 100.269953051643
- > str(t_fsyl)
- 'data.frame': 11153 obs. of 7 variables:
- $ long : num 17 17.1 17.1 17.1 17.1 ...
- $ lat : num 45.1 45.1 45 45 45 ...
- $ order: int 1 2 3 4 5 6 7 8 9 10 ...
- $ hole : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
- $ piece: Factor w/ 20 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
- $ group: Factor w/ 152 levels "100.269953051643.1",..: 1 1 1 1 1 1 1 1 1 1 ...
- $ id : chr "100.269953051643" "100.269953051643" "100.269953051643" "100.269953051643" ...
- ggplot(t_fsyl) + geom_polygon(aes(x=long, y=lat, fill=id))
- ggplot(t_fsyl) + geom_polygon(aes(x=long, y=lat, fill=group))
- library(rgdal)
- library(raster)
- #http://www.euforgen.org/fileadmin/templates/euforgen.org/upload/Documents/Maps/Shapefile/Fagus_sylvatica.zip
- fsyl <- readOGR(dsn=".", layer="Fagus sylvatica")
- #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_15.zip
- #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_16.zip
- #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_17.zip
- temp1 <- raster("bio1_15.bil")
- prcp1 <- raster("bio12_15.bil")
- temp2 <- raster("bio1_16.bil")
- prcp2 <- raster("bio12_16.bil")
- temp3 <- raster("bio1_17.bil")
- prcp3 <- raster("bio12_17.bil")
- temp <- merge(temp1, temp2, temp3)
- prcp <- merge(prcp1, prcp2, prcp3)
- te_pr <- addLayer(temp, prcp)
- projection(te_pr) <- CRS("+proj=longlat +datum=WGS84")
- fsyl <- spTransform(fsyl, CRS(projection(te_pr)))
- tp_fsyl <- extract(te_pr, fsyl, fun=mean, method="bilinear", sp=T)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement