You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用rasterize函数时类型不匹配错误的技术求助

问题:rasterize函数调用触发类型不匹配错误(MODIS EVI计算场景)

此前用于MODIS影像计算EVI的代码可正常运行,但现在调用rasterize函数时出现如下错误:

Error in (function (cond)  :  error in evaluating the argument 'x' in selecting a method for function 'is.factor': Not compatible with requested type: [type=character; target=double].

已在QGIS中分离出仅包含EVI信息的.tif文件,以下是使用的代码及影像、矢量数据详情:

代码片段

install.packages("C:/Users/Anto/Downloads/rgdal_1.4-3.tar.gz", repos=NULL, type='source')

library("raster")
library("rgdal")

setwd("C:/Users/Anto/Desktop/Comportamiento_cortisol/GIS_payunia/UTM19S/all_years_spring")

imagen <- raster("20110914_623_UTM19S.tif")   

shape <-readOGR("polig_N_UTM19S.shp")  
zones <- rasterize(shape, imagen, field = "id")  

# 重复调用用于测试
zones <- rasterize(shape, imagen, field = "id")  

影像数据详情

> imagen
class      : RasterLayer 
dimensions : 5120, 4799, 24570880  (nrow, ncol, ncell)
resolution : 393.1105, 224.7721  (x, y)
extent     : -296537.6, 1590000, 5530378, 6681211  (xmin, xmax, ymin, ymax)
crs        : +proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs 
source     : 20110914_623_UTM19S.tif 
names      : X20110914_623_UTM19S 
values     : -0.1998, 0.9411  (min, max)

矢量数据详情

> shape
class       : SpatialPolygonsDataFrame 
features    : 2 
extent      : 469983.2, 539187.8, 5984042, 6016778  (xmin, xmax, ymin, ymax)
crs         : +proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs 
variables   : 14
names       : id,        area, count,              sum,              mean,            median,             stdev,               min,               max, count_1,            sum_1,            mean_1,             min_1,             max_1 
min values  :  1, 202291562.4,  2293, 162.667400129139,  0.07094086355392, 0.068999998271465, 0.011263931890283,   0.0168999992311, 0.114500001072884,    2293, 162.667400129139,  0.07094086355392,   0.0168999992311, 0.114500001072884 
max values  :  2, 513447724.7,  5810,  428.03230074048, 0.073671652451029, 0.073600001633167, 0.012532315292168, 0.032499998807907, 0.116499997675419,    5810,  428.03230074048, 0.073671652451029, 0.032499998807907, 0.116499997675419 

内容的提问来源于stack exchange,提问作者MyName

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 22:22:50