繁体   English   中英

如何将 Corine 的土地覆盖类型分配和匹配到具有一组 lon lat 坐标的数据框?

[英]How to assign and match land cover type from Corine to a dataframe with a set of lon lat coordinates?

我试图找出一组坐标的土地利用类型,这些坐标定义了欧洲植物物种的位置。 但是,我被困在将土地使用分配给各个坐标的过程中。 任何建议都将受到欢迎!

首先,我从这里下载土地利用栅格文件: https ://land.copernicus.eu/pan-european/corine-land-cover

#Read raster file (year 2006 but could be any)
clc <- raster("U2006_CLC2000_V2020_20u1.tif")

然后,我阅读了 Corine 土地利用类并用这些类重命名了光栅文件的级别

#Read Corine classes
clc_classes <- foreign::read.dbf("CLC_1990/DATA/U2006_CLC2000_V2020_20u1.tif.vat.dbf",
                                 as.is = TRUE) %>%dplyr::select(value = Value,landcov = LABEL3)

这是我的完整坐标列表中的一小部分坐标(总共超过 200.000):

lon <- c("51.105", "51.195", "51.188", "51.239")
lat <- c("4.392", "4.395", "4.896", "4.468")
sp <- c("sp1","sp2", "sp3","sp4")
#Create minimal dataframe 
d <- data.frame(lon,lat,sp)

但是现在我真的不知道如何继续并创建具有土地利用类型的最终数据框,因为它与栅格文件匹配

我的意图是在我的坐标与栅格文件的土地利用类型匹配后添加如下第 4 列。

#Example of how this fourth column would be like:
d$land_use <- c("Olive groves", "Olive groves", "Vineyards", "Pastures")

数据(来自同一网站的另一个文件)。

library(terra)
r <- rast("U2018_CLC2018_V2020_20u1.tif")

如您所见, r知道类标签。

r
#class       : SpatRaster 
#dimensions  : 46000, 65000, 1  (nrow, ncol, nlyr)
#resolution  : 100, 100  (x, y)
#extent      : 9e+05, 7400000, 9e+05, 5500000  (xmin, xmax, ymin, ymax)
#coord. ref. : ETRS_1989_LAEA (EPSG:3035) 
#source      : U2018_CLC2018_V2020_20u1.tif 
#color table : 1 
#categories  : LABEL3, Red, Green, Blue, CODE_18 
#name        :                  LABEL3 
#min value   : Continuous urban fabric 
#max value   :                  NODATA 

head(cats(r)[[1]])
#  Value                                     LABEL3       Red     Green      Blue CODE_18
#1     1                    Continuous urban fabric 0.9019608 0.0000000 0.3019608     111
#2     2                 Discontinuous urban fabric 1.0000000 0.0000000 0.0000000     112
#3     3             Industrial or commercial units 0.8000000 0.3019608 0.9490196     121
#4     4 Road and rail networks and associated land 0.8000000 0.0000000 0.0000000     122
#5     5                                 Port areas 0.9019608 0.8000000 0.8000000     123
#6     6                                   Airports 0.9019608 0.8000000 0.9019608     124

以下是一些与extract一起使用的示例点

pts <- matrix(c(3819069, 3777007, 3775822, 2267450, 2302403, 2331431), ncol=2)
extract(r, pts)    
#                        LABEL3
#1                Sea and ocean
#2 Complex cultivation patterns
#3           Natural grasslands

或者使用您的 lon/lat 点(您的名称颠倒了!),首先将它们转换为土地利用栅格的坐标参考系统:

lat <- c(51.105, 51.195, 51.188, 51.239)
lon <- c(4.392, 4.395, 4.896, 4.468)
xy <- cbind(lon, lat) 
v <- vect(xy, crs="+proj=longlat")
vv <- project(v, crs(r)) 

extract(r, vv)
#  ID                                     LABEL3
#1  1               Complex cultivation patterns
#2  2 Road and rail networks and associated land
#3  3                                   Pastures
#4  4             Industrial or commercial units

如果您想要土地使用代码

activeCat(r) <- "CODE_18"
extract(r, vv)
#  ID CODE_18
#1  1     242
#2  2     122
#3  3     231
#4  4     121

罗伯特的回答真的很棒,可以帮助像我这样没有线索的人。 然而,当我尝试达到同样的效果时,我得到了意想不到的结果。

当我跑

library(terra)
data <- rast("2018_CLC2018_V2020_20u1.tif")
data

我没有标签:

class       : SpatRaster 
dimensions  : 46000, 65000, 1  (nrow, ncol, nlyr)
resolution  : 100, 100  (x, y)
extent      : 9e+05, 7400000, 9e+05, 5500000  (xmin, xmax, ymin, ymax)
coord. ref. : ETRS_1989_LAEA (EPSG:3035) 
source      : U2018_CLC2018_V2020_20u1.tif 
name        : U2018_CLC2018_V2020_20u1 
min value   :                        1 
max value   :                       48 

因此,提取的结果在 1 - 48 范围内。 这是我在网站上找到的唯一与命名匹配的文件。 很抱歉将此添加为答案,但我无法发表评论。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM