user3666974
user3666974

Reputation: 11

How to sync rasters with different projections

I would like to syncronize two geotiff files with different extent and different projection system. I'm try using spatial_sync_raster but it didnt work. How should I do ? Below are the details of the file.

class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 480, 480, 230400  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 480, 0, 480  (xmin, xmax, ymin, ymax)
coord. ref. : NA 
data source : D:\Test R\preqies\lc_2005.tif 
names       : lc_2005 
values      : 0, 255  (min, max)

class       : RasterLayer 
dimensions  : 869, 1201, 1043669  (nrow, ncol, ncell)
resolution  : 100, 100  (x, y)
extent      : 771507.8, 891607.8, 9788643, 9875543  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=47 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : D:\Test R\preqies\lc_2010.tif 
names       : lc_2010 
values      : 1, 22  (min, max)

I get error when tried this code

 landuse2<-spatial_sync_raster(landuse2, landuse1, method = "ngb")

**Error in rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, 2]) : 
  no arguments in initialization list**

can anyone tell me, whats part that make my code doesnt work? Thanks

Upvotes: 0

Views: 507

Answers (1)

Lucas
Lucas

Reputation: 11

try adding the same projection:

projection(landuse2)<- "+proj=utm +zone=47 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84"

landuse2<-spatial_sync_raster(landuse2, landuse1, method = "ngb")

I had the same problem and I solved the case. luck

Upvotes: 1

Related Questions