0

I am georeferencing a number of images using R. I can read the image in fine, and set an extent:

library(raster)
library(rgdal)
library(maptools)


## Read in the image as a raster 
my.raster <- raster("MyImage.tif")

## Read in previously gecoded maps
my.polygons<-readOGR("Poly.shp")

## Fix the extent
extent(my.raster)<-extent(my.polygons)
projection(my.raster) <- "+proj=longlat +datum=WGS84 +no_defs 
+ellps=WGS84 +towgs84=0,0,0"

But when I look at the file I see that the x and y resolutions are off:

class       : RasterLayer 
band        : 1  (of  3  bands)
dimensions  : 1935, 2511, 4858785  (nrow, ncol, ncell)
resolution  : 0.0006940597, 0.0003798972  (x, y)
extent      : -91.81082, -90.06803, 13.84329, 14.57839  (xmin, xmax, ymin, 
ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 
+towgs84=0,0,0

and then when I start manually changing the extent to match the shapefile I have, it only gets worse. If I resample(from the raster package), it gets worse again.

Can I georeference an image and keep the resolutions consistent so that when I export it to ArcGIS or whatever, it is properly placed?

I am not providing files, because the project has confidentiality issues.

4
  • What do you mean the x and y resolutions are "off"? What do you expect them to be? Are those the real extents of the raster?
    – Spacedman
    Commented Mar 7, 2018 at 19:35
  • They are inconsistent. The x and y resolutions are different. Yes, that's the real extent.
    – PSL
    Commented Mar 7, 2018 at 19:36
  • Are the original raster georeferenced at all? If they are, the greater longitude resolution might be an artifact of the projected CRS the original raster is in.
    – mkennedy
    Commented Mar 7, 2018 at 21:13
  • No, they are just tiffs, not georeferenced.
    – PSL
    Commented Mar 7, 2018 at 22:13

1 Answer 1

2

No, that is not possible. You have an image (raster dataset) with a fixed number of columns and rows. You can change the extent, but then the resolution must change because the (x) resolution is (extent.xmax - extent.xmin)/ncols. Likewise if you change the resolution, the extent must change.

My guess is that some of your assumptions are wrong. But it is hard to say without data. You can always provide non-confidential example data.

2
  • OK, thank you for your response. The main problem I am having, is that, although the raster file aligns properly with a polygon shape file in R, when I import the same raster into ArcGIS, it does not align with the same shapefile. I suspected that the inconsistent resolution might be at fault, but even when I force a consistent resolution on the raster, it displays incorrectly. Perhaps that is a different question.
    – PSL
    Commented Mar 7, 2018 at 21:08
  • Could be due to a faulty CRS. Arc corrects for CRS differences in display, R does not. Either way, it should be very easy to provide example data. Commented Mar 8, 2018 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.