r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
677 stars 146 forks source link

MODIS raster data acquired with projection problem #281

Closed rokoeh closed 2 years ago

rokoeh commented 2 years ago

Hello

I was trying to download MODIS data from product MOD13Q1 and I am facing a projection problem. The data that I downloaded using ee_as_raster came with an offset. It is not in the same area of my FeatureCollection.

require(rgee)
ee_Initialize(drive = TRUE)
mod09q1 <- ee$ImageCollection$Dataset$MODIS_006_MOD09Q1$filterDate("2022-06-01","2022-06-08")
shp<-ee$FeatureCollection("users/******/test1")
start <- ee$Date("2022-06-01")
end <- ee$Date("2022-06-08")
filter<-mod09q1$filterDate(start,end)
img <- filter$first()
img<-img$clip(shp)
img_b1<-img$select(c("sur_refl_b01"))
img_b2<-img$select(c("sur_refl_b02"))
img_qa<-img$select(c("QA"))
Map$setCenter(-46.8,-12.8, zoom = 7)
Map$addLayer(img,
             visParams=list(bands = c("sur_refl_b01", "sur_refl_b02"), min =100, max = 8000, gamma = c(1.9,1.7)),
             "False Color Image") 
ee_raster <- ee_as_raster(
  image = img_b1,
  region = shp$geometry(),
  dsn = "D:/temp/gee/test1_b1.tif",
  via = "drive"
)

Shapefile used in this test: test1.zip

Results:

p1

p2

p3

With best regards

ambarja commented 2 years ago

Excellent observation @rokoeh, but MODIS usually works with the Sinusual projection, however it can be solved using the following :point_down:

ee_raster <- ee_as_raster(
  image = img_b1$reproject('EPSG:4326', NULL, 500),
  region = shp,
  dsn = "/home/am/Imágenes/modis.tif",
  via = "drive"
  )

Captura de pantalla de 2022-08-10 16-31-09

rokoeh commented 2 years ago

That did it. Thank you.

Solved