All my shp. files, rasters and Spatial objects were projected to UTM NAD83. However, I need to convert them from meters to km for calculation reason. For rasters I can easily convert the "values" by dividing them with 1000. However when I plot them the coordinates were still in meters. It didn't look right if I convert the extent though (by dividing the extent with 1000). (ps. the resolution was 25 meters).
Are methods for converting meters to km different for .shp, spatial objects and rasters?
Eventually I would like to create a discrete distance-to-road surface in which the unit and the coordinate system were both in km.
##Read road shp.file
roads<-readOGR(dsn="E:/Doccuments/GIS", layer="Roads_2005_INDOT")
#coerce SpatialLinesDataFrame object to SpatialLines object
rd.spl<-as(roads, "SpatialLines")
#create an empty raster with the same extent and grid size=25
r<-raster(ext=extent(rd.spl), res=25)
rd.rs<-rasterize(rd.spl, r) #rasterize SpatialLine
#assign 0 to all roads values
rd.rs<-reclassify(rd.rs, c(0,108,0))
rd.rs
class : RasterLayer
dimensions : 125, 104, 13000 (nrow, ncol, ncell)
resolution : 25, 25 (x, y)
extent : 590847.7, 593447.7, 4235915, 4239040 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
data source : in memory
names : layer
values : 0, 0 (min, max)
plot(rd.rs)
#create discrete "distance-to-road" surface
d<-distance(rd.rs)/1000 #distance in km
plot(d)
plot(locations, add=TRUE)
plot(movements, add=TRUE)

