Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. > tp_fsyl
  2. class : SpatialPolygonsDataFrame
  3. features : 149
  4. extent : -6.776647, 35.13454, 37.74027, 59.70762 (xmin, xmax, ymin, ymax)
  5. coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
  6. variables : 3
  7. names : Id, layer.1, layer.2
  8. min values : 0, 47.1897926634769, 510.438502673797
  9. max values : 0, 138.237654320988, 1339.66159594342
  10.  
  11. t_fsyl <- fortify(tp_fsyl, region="layer.1")
  12.  
  13. > head(t_fsyl)
  14. long lat order hole piece group id
  15. 1 17.03176 45.09981 1 FALSE 1 100.269953051643.1 100.269953051643
  16. 2 17.08139 45.06541 2 FALSE 1 100.269953051643.1 100.269953051643
  17. 3 17.10079 45.04859 3 FALSE 1 100.269953051643.1 100.269953051643
  18. 4 17.12986 45.02336 4 FALSE 1 100.269953051643.1 100.269953051643
  19. 5 17.11578 45.00132 5 FALSE 1 100.269953051643.1 100.269953051643
  20. 6 17.06936 44.98166 6 FALSE 1 100.269953051643.1 100.269953051643
  21.  
  22. > str(t_fsyl)
  23. 'data.frame': 11153 obs. of 7 variables:
  24. $ long : num 17 17.1 17.1 17.1 17.1 ...
  25. $ lat : num 45.1 45.1 45 45 45 ...
  26. $ order: int 1 2 3 4 5 6 7 8 9 10 ...
  27. $ hole : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
  28. $ piece: Factor w/ 20 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
  29. $ group: Factor w/ 152 levels "100.269953051643.1",..: 1 1 1 1 1 1 1 1 1 1 ...
  30. $ id : chr "100.269953051643" "100.269953051643" "100.269953051643" "100.269953051643" ...
  31.  
  32. ggplot(t_fsyl) + geom_polygon(aes(x=long, y=lat, fill=id))
  33.  
  34. ggplot(t_fsyl) + geom_polygon(aes(x=long, y=lat, fill=group))
  35.  
  36. library(rgdal)
  37. library(raster)
  38.  
  39. #http://www.euforgen.org/fileadmin/templates/euforgen.org/upload/Documents/Maps/Shapefile/Fagus_sylvatica.zip
  40. fsyl <- readOGR(dsn=".", layer="Fagus sylvatica")
  41.  
  42. #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_15.zip
  43. #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_16.zip
  44. #http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/tiles/cur/bio_17.zip
  45. temp1 <- raster("bio1_15.bil")
  46. prcp1 <- raster("bio12_15.bil")
  47.  
  48. temp2 <- raster("bio1_16.bil")
  49. prcp2 <- raster("bio12_16.bil")
  50.  
  51. temp3 <- raster("bio1_17.bil")
  52. prcp3 <- raster("bio12_17.bil")
  53.  
  54. temp <- merge(temp1, temp2, temp3)
  55. prcp <- merge(prcp1, prcp2, prcp3)
  56.  
  57. te_pr <- addLayer(temp, prcp)
  58.  
  59. projection(te_pr) <- CRS("+proj=longlat +datum=WGS84")
  60.  
  61. fsyl <- spTransform(fsyl, CRS(projection(te_pr)))
  62.  
  63. tp_fsyl <- extract(te_pr, fsyl, fun=mean, method="bilinear", sp=T)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement