R에서 위도 / 경도에서 UTM으로 래스터를 재 투영합니까?


13

버퍼를 작동 시키려면 UTM으로 바꿔야합니다.

wets<-readOGR(dsn=".",layer="shapefile")
r.raster <- raster()
extent(r.raster) <- extent(wets)
res(r.raster) <- 100 

wets.r <- rasterize(wet,r.raster)
plot(wets.r)
wetsbuf<-buffer(wets.r,width=500)

마지막 코드 행인 버퍼 작성 중에 다음 경고가 표시됩니다.

Warning message:  
In couldBeLonLat(x) :
  raster has a longitude/latitude CRS, but coordinates do not match that

여기 정보가 있습니다

  summary(wets.r)
          layer
 Min.        1
 1st Qu.     1
 Median      2
 3rd Qu.     9
 Max.       11
 NA's    52629

summary(wets)

  Object of class SpatialPolygonsDataFrame
Coordinates:
      min       max
 x  683705  714088.8
 y 4326266 4343768.0
 Is projected: TRUE 
 proj4string :
 [+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +datum=GGRS87
 +units=m +no_defs +ellps=GRS80 +towgs84=-199.87,74.79,246.62]
 Data attributes:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    0.0     2.5     5.0     5.0     7.5    10.0 






 wets.r

class       : RasterLayer 
dimensions  : 175, 304, 53200  (nrow, ncol, ncell)
resolution  : 100, 100  (x, y)
extent      : 683705, 714105, 4326268, 4343768  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : 1, 11  (min, max)
attributes  :
   ID FID
 from:  1   0
 to  : 11  10

버퍼를 만들려면 prjection을 변경해야합니다.


투영 좌표계 또는 지리적 CS의 데이터입니까?
— Aaron

초기 벡터 데이터는 내가 생각하는 투영 좌표계에 있습니다.
— gsa

예상 (예 : UTM) 또는 지리적 (위도 / 경도)?
— Aaron

나는 이것을 확인하는 방법을 모른다 나는 UTM bu t 나는 확실하지 않다고 생각한다
— gsa

좌표는 무엇이며 어느 지역 (주, 도시)에 있습니까?
— ed.hank

답변:


16

이것이 래스터 패키지를 사용하여 R에서 래스터를 재 투영하는 방법 입니다. 이 예에서 입력 지오메트리는 NAD83 지리 좌표계에 있었고 NAD 83 UTM 15 투영 좌표계로 다시 투영합니다. RGDAL 의해 사용되는 포맷 Proj4 돌기위한 양호한 기준은에서 찾을 수 spatialreference.org .

library(raster)

# Create RasterLayer object
r <- raster('C:/temp/binary_nad83.tif')

# Define the Proj.4 spatial reference 
# http://spatialreference.org/ref/epsg/26915/proj4/
sr <- "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs" 

# Project Raster
projected_raster <- projectRaster(r, crs = sr)

# Write the RasterLayer to disk (See datatype documentation for other formats)
writeRaster(projected_raster, filename="C:/temp/binary_utm15.tif", datatype='INT1U', overwrite=TRUE)

대답 주셔서 감사합니다,하지만 그것을 반환합니다 : projectExtent (from, projto)의 오류 :이 변환을 수행 할 수 없습니다 또한 : 경고 메시지 : rgdal :: rawTransform (projfrom, projto, nrow (xy), xy [, 1], xy [, : 218 예상 포인트 유한하지 않음
— gsa

단일 대역 래스터 또는 다중 대역을 사용하고 있습니까? 이 예는 단일 대역 래스터입니다.
— Aaron

그것은 위성 이미지가 아닌 벡터 (습지)의 래스터 화 프로세스에서 비롯되므로 단일 밴드로 갈 것입니다.
— gsa

래스터 / rgal 패키지를 업데이트하십시오 : r-sig-geo.2731867.n2.nabble.com/…
— Aaron

@gsa, 이것이 효과가 있다면 답을 찬성하고 받아들이는 것이 좋습니다! 그렇지 않으면 원래 질문을 편집하고 명확하게하십시오.
— Simbamangu
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.