i have to turn it into a UTM in order to make the buffer functional.

r.raster <- raster()
extent(r.raster) <- extent(wets)
res(r.raster) <- 100 

wets.r <- rasterize(wet,r.raster)

During the buffer creation which is the last line of code, it gives this warning:

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

here's the info

 Min.        1
 1st Qu.     1
 Median      2
 3rd Qu.     9
 Max.       11
 NA's    52629


  Object of class SpatialPolygonsDataFrame
      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 


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  :
 from:  1   0
 to  : 11  10

I have to change the prjection in order to be possible to do the buffer.

  • Is you data in a projected coordinate system or a geographic CS? – Aaron Jul 13 '15 at 20:23
  • The initial vector data are in a projected coordinate system i think. – gsa Jul 13 '15 at 20:33
  • Projected (e.g. UTM) or Geographic (lat/lon)? – Aaron Jul 13 '15 at 20:36
  • I dont know how to check this i think UTM bu t i'm not certain – gsa Jul 13 '15 at 20:40
  • what are the coordinates and which area (state, city) are you in? – ed.hank Jul 13 '15 at 20:42

This is how you can reproject a raster in R using the raster package. In this example, the input geotiff was in a NAD83 geographic coordinate system and I reproject to a NAD 83 UTM 15 projected coordinate system. A good reference for Proj4 format projections, which are used by RGDAL, can be found at spatialreference.org.


# 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)
  • Thanks for the answer, it returns this though : Error in projectExtent(from, projto) : cannot do this transformation In addition: Warning message: In rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, : 218 projected point(s) not finite – gsa Jul 14 '15 at 14:12
  • Are you using a single band raster or a multiband? This example is is for a single band raster. – Aaron Jul 14 '15 at 14:19
  • It comes from a rasterize process of a vector (wetlands) not a satellite image so i will go with the single band. – gsa Jul 14 '15 at 14:22
  • Try updating your raster/rgal packages: r-sig-geo.2731867.n2.nabble.com/… – Aaron Jul 14 '15 at 15:29
  • @gsa, if this works it's a good idea to upvote and accept the answer! Otherwise, edit and clarify your original question. – Simbamangu Oct 20 '15 at 4:41

Your Answer

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

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