Using R I'd like to create a raster from a set of contour shape files, where each cell in the raster contains a value for the derived gradient.
I am using OS Terrain 50 contour lines which is open data from, the Ordnance Survey: https://www.ordnancesurvey.co.uk/opendatadownload/products.html
* UPDATED QUESTION *
As requested, here is how I've approached the problem so far, which hasn't really worked and I'm not sure why.
Firstly I load my contour shapefile:
c <- readOGR("osrastersandvectors/terrain_shape_files/HP40_line.shp")
Then the following to create a raster at 10m resolution:
c.raster <- raster() extent(c.raster) <- extent(c) res(c.raster) <- 10
Then I rasterize:
c.raster <- rasterize(c,c.raster)
This works in that I get a raster of the original contour lines, where cell values are elevation. Note, there are no elevation values beyond where the original contour lines are. Then I'm thinking I need to calculate a value for each cell, given the contour line values. So some form of interpolation to give slope (gradient?). So something along the lines of:
slope = terrain(c.raster, opt=c('slope'), unit = 'degrees', neighbours=8)
This returns a raster but it's not what I want: a single layer raster where each cells value represents the gradient at that point.