You could use gdal_rasterize either from the command line or QGIS to generate your raster. To make sure your points sit within a cell, you need to do two things. First, set the target resolution to 5m, and set the extents to be 2.5m bigger all around than the source data.
So, assuming your dataset goes from [1000 2000] [2500 3250]
, giving you your 75,000 points, you'd use something like this:
gdal_rasterize -3d -te 997.5 1997.5 2502.5 3252.5 -tr 5.0 5.0 -ot Float32 -l heights dem.shp dem.tif
This assumes your height data is in a Z point attribute, otherwise just use -a <attribute_name>
instead of -3d
I see this has already been solved by the Original Poster (OP), but I'll post a simple solution in python just in case anyone in the future is interested in different ways to solve this problem. I'm partial to open source software, so here's a solution using GDAL in python:
import gdal
#Set GeoTiff driver
driver = gdal.GetDriverByName("GTiff")
driver.Register()
#Open raster and read number of rows, columns, bands
dataset = gdal.Open(filepath)
cols = dataset.RasterXSize
rows = dataset.RasterYSize
allBands = dataset.RasterCount
band = dataset.GetRasterBand(1)
#Get array of raster cell values. The two zeros tell the
#iterator which cell to start on and the 'cols' and 'rows'
#tell the iterator to iterate through all columns and all rows.
def get_raster_cells(band,cols,rows):
return band.ReadAsArray(0,0,cols,rows)
Implement the function like this:
#Bind array to a variable
rasterData = get_raster_cells(band,cols,rows)
#The array will look something like this if you print it
print rasterData
> [[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]]
Then, iterate through your data with a nested loop:
for row in rasterData:
for val in row:
print val
> 1
2
3
4...
Or maybe you want to flatten your 2-D array with a list comprehension:
flat = [val for row in rasterData for val in row]
Anyways, while iterating through the data on a cell-by-cell basis its possible to throw some conditionals into your loop to change/edit values. See this script I wrote for different ways to access the data: https://github.com/azgs/hazards-viewer/blob/master/python/zonal_stats.py.
Best Answer
Because a raster is continuous and points are discrete, you will need to use an interpolation method to create the kind of raster you would like. There are several different interpolation methods that may be better or worse for a specific application - but, here is a pretty brief overview of interpolation: http://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/understanding-interpolation-analysis.htm
And here is a brief overview of the different interpolation methods offered in ArcMap: http://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/comparing-interpolation-methods.htm.
Once you have interpolated a raster surface, you can clip to the UK boundary.