我一直在尝试栅格化在R中导入的shp列表。当我调用列表时出现错误,因为它不能识别为数据帧而是作为字符识别。我试图使用 as.dataframe(list [i])但没有成功。
错误:无法为签名'“character”,“RasterLayer”'
找到函数'rasterize'的继承方法var imageBitmap = ImageHelper.GetImageBitmapFromUrl("http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png");
hotDogImageView.SetImageBitmap(imageBitmap);
答案 0 :(得分:0)
以下是一些注意事项
readOGR
不适用于您提供的参数。 shapefile
函数会。我更改了变量名称,因为在将数据读入R后,它们不再是shapefile。大概是SpatialPolygonsDataFrame
个对象
library(raster)
p_ELC <- shapefile("EconomicLandConsesions/ELC.shp")
p_CF <- shapefile("Communityforestry/Community_forestryPolygon.shp")
p_NPA <- shapefile("Natural-Protected-Areas/Natural Protected Areas.shp")
p_Ecoregion <- shapefile("TerrestrialEcoRegionsWWF/KH_TerrEcoregions_Dslv.shp")
# you can create a list right away, but with only a few objects that might make things harder for you
# f <- c("EconomicLandConsesions/ELC.shp", "Communityforestry/Community_forestryPolygon.shp", "Natural-Protected-Areas/Natural Protected Areas.shp", "TerrestrialEcoRegionsWWF/KH_TerrEcoregions_Dslv.shp")
# pList <- lapply(f, shapefile)
显然有些多边形有UTM CRS,而有些则没有。 确保它们都转换为相同的CRS。
utmcrs <- crs(p_CF)
p_Ecoregion <- spTransform(p_Ecoregion, utmcrs)
# create Raster template
r <- raster(resolution=30, ext = extent(p_Ecoregion), crs = utmcrs)
# make a list of the SpatialPolygonDataFrame objects
listP <- list(p_ELC, p_CF, p_NPA, p_Ecoregion)
我不知道现在该做什么。在您的示例中,您将覆盖输出三次。我假设你想要四个栅格
x <- list()
for(i in 1:length(listP)){
x[[i]] <- rasterize(listP[[i]]), r)
}
s <- stack(x)
plot(s)