I have a raster map with 202 rows and 201 columns there are some grids in this map which pixel values is 0 I want to write a function that return all the pixel values 0 grids' coordinate how can I do it I was trying to use if loop and while loop but it always says TRUE/FALSE need here is my sample code
library(raster)
library(rgdal)
library(maptools)
library(sp)
setwd("E:/Landsat-data-NASA atm-corrected/sample_day1")
restdir2 <- ("E:/Landsat-data-NASA atm-corrected/sample_day1")
n3 <- list.files(restdir2, pattern="*band4_clip_1.tif", full.names=TRUE)
n4 <- list.files(restdir2, pattern="*cloud_qa_clip_1.tif", full.names=TRUE)
n5 <- list.files(restdir2, pattern="*cloud.tif", full.names=TRUE)
create<- function(x,y)
{
layer <- raster(n4)
layer2 <- raster(n3)
for(c in 1:x)
{
for(r in 1:y)
{
nl<- layer2
if(layer[c,r]==0)
return layer[c,r]
}
}
}
create (10,10)
Aucun commentaire:
Enregistrer un commentaire