저는 에 새 소식입니다.이 질문은 매우 기본적인 것이지만 나는 그걸로 어려움을 겪고 있으며 해결 된 해결책을 찾지 못했습니다. 같은 영역의 일부 landsat 이미지에서 래스터 벽돌을 만들고 싶습니다. HDF-EOS
형식으로 다운로드되었으며 Modis 재 투영 도구을 사용하여 .tif
으로 변환했습니다.다른 범위의 래스터로 래스터 벽돌을 만드는 방법은 무엇입니까?
결과 래스터는 같은 투영법을 갖지만 범위, 해상도 및 원점이 다릅니다. 수동으로 하위 집합의 범위를 정의하고 모든 래스터를 부분 집합
:
나는 몇 여기 아래에 요약 접근을 시도했다. 그런 다음 서브셋 래스터로 벽돌을 만들려고 시도합니다.래스터를 리샘플링하여 동일한 수의 열과 행을 제공합니다. 이상적으로는 래스터 셀을 정렬하고 래스터 벽돌에 넣을 수 있습니다. 이 옵션은 래스터에 값이없는 벽돌을 만들었지 만 비어있었습니다.
범위를 수정해야하는 이유는 무엇입니까? 가져온 landsat 이미지의 값으로 나중에 채울 빈 래스터를 만드는 것이 정확하고 (효율적일 수 있습니까?) 내가 실수를하고있는 곳을 볼 수 있니? 이 관련이 경우 , 내가 rgdal 인 버전 맥 OS X 버전 10.9.1 작업, 그리고 사용하고 0.8-14
은 어떤 도움이 매우 이해할 수있을 것이다!
감사합니다
내가 여기 내가 사용 된 코드를 추가 : 여기
# .tif files have been creating using the Modis Reprojection Tool. Input
# files used for this Tool was LANDSAT HDF-EOS imagery.
library(raster)
library(rgdal)
setwd()=getwd()
# Download the files from dropbox:
dl_from_dropbox <- function(x, key) {
require(RCurl)
bin <- getBinaryURL(paste0("https://dl.dropboxusercontent.com/s/", key, "/", x),
ssl.verifypeer = FALSE)
con <- file(x, open = "wb")
writeBin(bin, con)
close(con)
message(noquote(paste(x, "read into", getwd())))
}
dl_from_dropbox("lndsr.LT52210611985245CUB00-vi.NDVI.tif", "qb1bap9rghwivwy")
dl_from_dropbox("lndsr.LT52210611985309CUB00-vi.NDVI.tif", "sbhcffotirwnnc6")
dl_from_dropbox("lndsr.LT52210611987283CUB00-vi.NDVI.tif", "2zrkoo00ngigfzm")
# Create three rasters
tif1 <- "lndsr.LT52210611985245CUB00-vi.NDVI.tif"
tif2 <- "lndsr.LT52210611985309CUB00-vi.NDVI.tif"
tif3 <- "lndsr.LT52210611987283CUB00-vi.NDVI.tif"
r1 <- raster(tif1, values=TRUE)
r2 <- raster(tif2, band=1, values=TRUE)
r3 <- raster(tif3, band=1, values=TRUE)
### Display their properties
# projection is identical for the three rasters
projection(r1)
# "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
projection(r2)
projection(r3)
# Extents are different
extent(r1)
# class : Extent
# xmin : -45.85728
# xmax : -43.76855
# ymin : -2.388705
# ymax : -0.5181549
extent(r2)
# class : Extent
# xmin : -45.87077
# xmax : -43.78204
# ymin : -2.388727
# ymax : -0.5208711
extent(r3)
# class : Extent
# xmin : -45.81952
# xmax : -43.7173
# ymin : -2.405129
# ymax : -0.5154312
# origin differs for all
origin(r1)
# 5.644590e-05 -8.588605e-05
origin(r2)
# 0.0001122091 -0.0001045107
origin(r3)
# 6.949976e-05 -5.895945e-05
# resolution differs for r2
res(r1)
# 0.0002696872 0.0002696872
res(r2)
# 0.0002696875 0.0002696875
res(r3)
# 0.0002696872 0.0002696872
## Try different approaches to create a raster brick
# a- define a subset extent, and subset all the rasters
plot(r1, main="layer1 NDVI")
de <- drawExtent(show=TRUE, col="red")
de
# class : Extent
# xmin : -45.36159
# xmax : -45.30108
# ymin : -2.002435
# ymax : -1.949501
e <- extent(-45.36159,-45.30108,-2.002435,-1.949501)
# Crop each raster with this extent
r1c <- crop(r1,e)
r2c <- crop(r2,e)
r3c <- crop(r3,e)
# Make raster brick
rb_a <- brick(r1c,r2c,r3c)
# Error in compareRaster(x) : different extent
# b- Resample each raster
s <- raster(nrow=6926, ncol=7735) # smallest nrow and ncol among r1,r2 and r3
r1_res <- resample(r1,s, method="ngb")
r2_res <- resample(r2,s, method="ngb")
r3_res <- resample(r3,s, method="ngb")
# Resampling gives for the three rasters the following message:
# Warning message:
# In .local(x, y, ...) :
# you are resampling y a raster with a much larger cell size,
# perhaps you should use "aggregate" first
# Make raster brick
rb_c <- brick(r1, r2, r3)
# Error in compareRaster(x) : different extent
을 당신도 깜빡 생각 로드'라이브러리 (RCurl)'? –
** projectRaster() ** instound ** resample **을 사용하여 시도한 적이 있습니까? b 메서드에서? –