[英]Create a list of Spatial Polygon dataframe from a list of dataframe
I want Create a list of Spatial Polygon dataframe from a list of dataframe. 我想从数据框列表中创建空间多边形数据框列表。 The list of Spatial polygons is called list_sp_Tanzania
and the list of dataframe is called list_df_Tanzania_Modis500
. 空间多边形的列表称为list_df_Tanzania_Modis500
,数据list_sp_Tanzania
的列表称为list_df_Tanzania_Modis500
。 Each list contains 61 objects and each objects contains several polygons. 每个列表包含61个对象,每个对象包含几个多边形。
str(list_df_Tanzania_Modis500)
$ :'data.frame': 30 obs. of 11 variables:
..$ ID : int [1:30] 296 298 321 323 324 330 331 361 419 453 ...
..$ LU_1990 : int [1:30] 11 11 11 11 11 11 11 11 11 11 ...
..$ LU_2000 : num [1:30] 12 12 12 12 12 12 12 12 12 12 ...
..$ CHLU_90_00: chr [1:30] "1112" "1112" "1112" "1112" ...
..$ LU_2005 : num [1:30] 12 12 12 12 12 12 12 12 12 15 ...
..$ CHLU_00_05: chr [1:30] "1212" "1212" "1212" "1212" ...
..$ Tile : Factor w/ 1 level "S11_E039": 1 1 1 1 1 1 1 1 1 1 ...
..$ UNIQ_ID : Factor w/ 30 levels "S11_E039_296",..: 1 2 3 4 5 6 7 8 9 10 ...
..$ AREA : num [1:30] 219337 347133 393961 181875 105137 ...
..$ Sour_90_00: chr [1:30] "Modis500_2000" "Modis500_2000" "Modis500_2000" "Modis500_2000" ...
..$ Sour_00_05: chr [1:30] "Modis500_2005" "Modis500_2005" "Modis500_2005" "Modis500_2005" ...
str(list_sp_Tanzania)
[[61]]
class : SpatialPolygons
features : 30
extent : 38.95413, 39.04577, -11.04522, -10.95469 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
Unfortunately, I cannot provide the data with dput
because they are s4 objects
and I could not find similar examples. 不幸的是,我无法为数据提供dput
因为它们是s4 objects
并且找不到类似的示例。 Hope someone can help me somehow though. 希望有人能以某种方式帮助我。
Here is the solution. 这是解决方案。
fun <- function(x, y) {
SpatialPolygonsDataFrame(x, y, match.ID = F)
}
list_Spdf_Tanzania_Modis500 <- mapply(FUN = fun,
x = list_sp_Tanzania,
y = list_df_Tanzania_Modis500)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.