R:RasterToPolygon工作缓慢,然后停止工作 [英] R: RasterToPolygon works slow, then stop working
问题描述
即使我以前已经完成过处理R中的栅格的问题,我也遇到了问题.我可以读取数据并绘制它们:
I have a problem to process rasters in R, even if I've done it previously. I can read the data and plot them:
但是,当我尝试将栅格转换为多边形时,R停止工作
however, when I tried to convert my raster to polygon, the R stops working
我尝试更新软件包,在Windows 7的OSX上重新安装R,总是得到相同的结果.
I've tried to update packages, re-install R, on OSX, on Windows 7, always with the same result.
此外,我尝试将投影设置为NA,但这都没有帮助.您是否遇到过这样的问题?您对解决问题有什么建议吗?我非常感谢任何建议!
Moreover, I've tried to set my projection to NA, but this neither helped. Did you ever experienced problem like this? Do you have some suggestions how to solve the problem? I highly appreciate any suggestions !
我的数据在这里: https://ulozto.sk/x4pHuyra/data-堆叠zip
还有我的代码:
library(sp)
library(raster)
library(rgeos)
library(spatstat)
library(rgdal)
library(maptools)
require(spdep)
# read final GFW raster - in JTSK
gfw_13<-raster("H:/.../gfw_ext_forest_03.tif")
projection(gfw_13)<-NA
# read shp
manag<-readOGR(dsn = "H:/...",
layer = "cleared_management_by_NP")
projection(manag)<-NA
# convert raster GFW to shp # !!!!! here it stops to work
pol.gfw<-rasterToPolygons(gfw_13, dissolve = T)
推荐答案
这不能解决速度问题,但是至少我的进程运行并且R不会崩溃...我需要为 rasterToPolygon
函数:
This doesn't solve the speed problem, but at least my processes run and R doesn't crashes... I need to define all arguments for rasterToPolygon
function:
pol.gfw <- rasterToPolygons(gfw_13, fun=NULL, n=4, na.rm=TRUE, digits=12, dissolve=TRUE)
也许是由于原始栅格中大量的NA值所致.
Maybe the problem was due to abundant numbers of NA values in the original raster..
这篇关于R:RasterToPolygon工作缓慢,然后停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!