I am very new to image analysis and GIS. I tried to resample a tiff file based on a reference raster, the following is the code and objects I have:

class       : RasterLayer 
band        : 1  (of  2  bands)
dimensions  : 7311, 6124, 44772564  (nrow, ncol, ncell)
resolution  : 0.08541, 0.08541  (x, y)
extent      : 225357.8, 225880.8, 2585532, 2586156  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=51 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : /Users/shu-yunchen/Desktop/UVA_related_articals/Images_for_testing/Image/20160929/reflectance/1214_multi_transparent_reflectance_green.tif 
names       : X1214_multi_transparent_reflectance_green 

class       : RasterStack 
dimensions  : 25223, 19462, 490890026, 4  (nrow, ncol, ncell, nlayers)
resolution  : 0.02973, 0.02973  (x, y)
extent      : 179774.1, 180352.7, 2583827, 2584577  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=51 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
names       : X1005_rgb_a7_transparent_mosaic_group1.1, X1005_rgb_a7_transparent_mosaic_group1.2, X1005_rgb_a7_transparent_mosaic_group1.3, X1005_rgb_a7_transparent_mosaic_group1.4 
min values  :                                        0,                                        0,                                        0,                                        0 
max values  :                                      255,                                      255,                                      255,                                      255 

What I tried is resample the three layers of RGB_1 with Green_stage_1 as followed:


What I got is an error message:

Error in .intersectExtent(x, y, validate = TRUE) : Objects do not intersect

This "resample" way worked well with my other two RGB files (RGB_2 and RGB_3) which the coordinate are:

+proj=utm +zone=51 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0

So I tried to solve the different coordinate issue between RGB_1 and Green_stage_1, I tried:

RGB_reprojected <- spTransform(RGB,CRS(Green_stage_1))

Another error message I got:

Error in !is.na(projargs) && !nzchar(projargs) : invalid 'x' type in 'x && y'

  • 1
    Are you using GDAL and R for doing this resampling? Your code chunk is showing only the raster metadata, so hard to tell what is going wrong with the actual code. The extents are different and the error is complaining about not intersecting each other. Have you checked the layers visually? For fixing projection issue, reprojecting it using QGIS might be quicker. – Hasnein Tareque Jun 18 '18 at 4:13
  • If you want to reproject raster use projectRaster, spTransform is for vectors. Looks like both RGB_1 and Green_stage_1 are in same projection system, but extent is different. – S. Thiyaku Jun 18 '18 at 4:32
  • 1
    If you know that both images cover the same area then re-projection is not what you must do. Re-projection does not move the image on the ground. After re-projection images are expressed in a different coordinate system but they still don't overlap. If one of the images is not really in UTM Zone 51, don't reproject but give a correct +proj string for it. – user30184 Jun 18 '18 at 7:59
  • Hi, thanks a lot for your kind replies. The two images "Green_stage_1" and "RGB_1" are taken from different cameras in one UAV, however, the GPS system went wrong, so the coordinate and extent of images are totally different. I tried to change the CRS of "RGB_1" into "utm +zone=51 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 " which as "Green_stage_1", but still can't figure out how to put these two images together with such different extent. Any suggestions will help a lot, thanks. – Shu-Yun Chen Jun 19 '18 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.