Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
裁剪R中有多边形的光栅:错误范围不重叠_R_Image Processing_Crop_Raster - Fatal编程技术网

裁剪R中有多边形的光栅:错误范围不重叠

裁剪R中有多边形的光栅:错误范围不重叠,r,image-processing,crop,raster,R,Image Processing,Crop,Raster,我想使用我在ArcGIS中制作的多边形形状文件裁剪光栅堆栈,但我得到的错误是范围不重叠 首先,我创建光栅堆栈: test1 < stack("C:/mydir/test1.tif") 这一信息不言自明。您的范围不重叠。。。以下是如何检查: library(raster) ext.ras <- extent(6e+05, 709800, 5690220, 5800020) ext.pol <- extent(499386.6, 517068.2, 6840730, 685727

我想使用我在ArcGIS中制作的多边形形状文件裁剪光栅堆栈,但我得到的错误是范围不重叠

首先,我创建光栅堆栈:

test1 < stack("C:/mydir/test1.tif")

这一信息不言自明。您的范围不重叠。。。以下是如何检查:

library(raster)
ext.ras <- extent(6e+05, 709800, 5690220, 5800020)
ext.pol <- extent(499386.6, 517068.2, 6840730, 6857271)


plot(ext.ras, xlim = c( 499386.6,709800), ylim= c(5690220,6857271), col="red")
plot(ext.pol, add=T, col="blue")
库(光栅)

谢谢你,我按照你的建议使用了readOGR()和spTransform(),效果非常好。这可能是因为,在调用myExtent时
myExtent <- readShapePoly("C:/mydir/loc1.shp", verbose=TRUE, proj4string=myCRS)
myCrop <- crop(test1, myExtent)
Error in .local(x, y, ...) : extents do not overlap
> test1$test1.1
class       : RasterLayer 
band        : 1  (of  4  bands)
dimensions  : 10980, 10980, 120560400  (nrow, ncol, ncell)
resolution  : 10, 10  (x, y)
extent      : 6e+05, 709800, 5690220, 5800020  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 
+towgs84=0,0,0 
data source : C:\mydir\test1.tif 
names       : test1.1 
values      : 0, 65535  (min, max)

> myExtent
class       : SpatialPolygonsDataFrame 
features    : 1 
extent      : 499386.6, 517068.2, 6840730, 6857271  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=31 +datum=WGS84 +units=m +no_defs +ellps=WGS84 
+towgs84=0,0,0 
variables   : 2
names       :    Shape_Leng,    Shape_Area 
min values  : 67444.6461177, 283926851.657 
max values  : 67444.6461177, 283926851.657 
library(raster)
ext.ras <- extent(6e+05, 709800, 5690220, 5800020)
ext.pol <- extent(499386.6, 517068.2, 6840730, 6857271)


plot(ext.ras, xlim = c( 499386.6,709800), ylim= c(5690220,6857271), col="red")
plot(ext.pol, add=T, col="blue")
myExtent <- readShapePoly("C:/mydir/loc1.shp", verbose=TRUE, proj4string=myCRS)
library(rgdal)
myExtent <- readOGR("C:/mydir","loc1.shp")
myExtent <- spTRansform(myExtent, CRS(proj4string(test1)))