||
基于地理坐标提取地图中的属性信息
问题:现有全国范围内的样地分布地点,已知它们的WGS84经纬度,如何用R从植被分区图中提取每个点的植被分区信息?
#### 植被图下载 https://xg1990.com/blog/archives/97
#### R代码:
setwd("/working directory/")
library(openxlsx)
library(maptools)
library(sp)
point_dat <- read.xlsx("sites.xlsx")
coordinates(point_dat) <- cbind(point_dat$longitude , point_dat$latitude)
##### 植被分区图下载地址
##### http://xg1990.com/blog/wp-content/uploads/2012/09/%E4%B8%AD%E5%9B%BD%E6%A4%8D%E8%A2%AB%E5%8C%BA%E5%88%92.poly_.WGS84.zip
county <- readShapePoly("china_vegetation_polygon.WGS84")
plot(county)
extracted = over(point_dat, county)
res <- data.frame(point_dat, extracted)
write.xlsx(res, "extracted_by_points.xlsx
数据和代码的下载地址: extract value from polygon.zip
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-7 08:21
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社