jpg_file <-"D:/qunluo/qunluo.jpg"
qunluo <- raster(jpg_file)
qunluo_matrix <- as.matrix(qunluo)
qunluo_rgb <- rgb(qunluo_matrix,qunluo_matrix,qunluo_matrix,maxColorValue = 255)
writeRaster(qunluo_rgb, filename = "D:/qunluo/qunluorgb1.tif", format = "GTiff", overwrite = TRUE)
#出现函数‘writeRaster’标签‘"character", "character"’找不到继承方法的错误解决不了
TIF_extent <- extent(0,0,0,0) #里面的数字表示裁剪的影像xmin,xmax,ymin,ymax
tif_extent <- crop(tif,TIFextent) #在tif中按照TIFextent的范围裁剪,形成新文件
tif_pixel <- ncell(tif_extent) #计算tif_extent的栅格数量
library(magick) #jpg图片转换为TIF文件
photo <- image_read("D:/qunluo/qunluo.jpg")
image_write(photo,path = "D:/qunluo/qunluo1.tif")
count <- length(which(carex[] >= 0 & carex[] <= 1))
#计算一定值域范围内的像元数量