簡體   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