User:EdLoach/Tendring LIDAR

From OpenStreetMap Wiki
Jump to: navigation, search

Tendring LIDAR

It all started with User:Chillly's blog post about the UK Environment Agency LIDAR data.

I decided to download the data which covered the Tendring district, and after a bit of trial and error decided I liked the look of the DSM data better as it showed buildings more clearly. The area I downloaded was TM01, TM02, TM03, TM11, TM12, TM13, TM21, TM22 and TM23 which includes a bit more than Tendring, but was the smallest area I could download that included the whole district.

The files come as ZIP files containing a .asc file for each 1km square for the squares with any data. If you have QGIS you can have a look at one of the .asc files by doing the following (notes based on v2.4):

  • Select the menu option Layer, Add Raster Layer
  • Specify a file type of 'Arc/Info ASCII grid' and select the .asc file to Open
  • I specified OSGB 1936 (EPSG:4277) as the CRS. If you're not overlaying other layers it probably won't matter greatly.

These steps allow you to have a look at the contents of the .asc files without lots of processing, and was how I decided to go with the DSM data.

I used a Ubuntu 14.04 virtual machine running in Virtualbox and gave it 4GB RAM, 1 processor and a 200GB drive (to be completely accurate, I used an existing virtual machine and increased the RAM to 4GB and had to resize the drive when it got full and gave it an extra 200GB). I don't know Ubuntu/Linux much but went to Ubuntu Software Centre and searched for and installed gdal-bin and python-gdal somehow. After that following the blog was fairly straightforward.

  • Ctrl+Alt+T opens a terminal window
  • mkdir Lidar creates a folder called Lidar
  • cd Lidar changes into that folder
  • Beneath those I made separate folders for 2m, 1m, 50cm, 25cm and unzipped the downloaded zip files into the relevant one (all asc files to the one folder).
  • I started with 2m (each time the resolution doubles there is 4 times as much data, although coverage also reduces so it isn't exactly 4 times).
  • cd 2m changed into the folder
  • mkdir relieftiff creates the folder called relieftiff to create tif files in
  • for f in *.asc ; do gdaldem hillshade -compute_edges "$f" "relieftiff/${f%.asc}.tif" ; done
  • the above created one tif file for each asc file
  • cd relieftiff (when the command completed) changed into the folder where the tif files are
  • -o big.tif *.tif
  • above command merged the small tif files into a single file called big.tif
  • gdalwarp -s_srs epsg:27700 -t_srs epsg:4326 -srcnodata 0 -dstalpha big.tif bigr.tif
  • above command warps from OSGB to WGS84 creating new tif called bigr.tif - note that on a clean ubuntu installation you might get an error about EPSG:900913 and you will need to amend a .py file as described here
  • mkdir tiles (creates a file to create the tiles beneath)
  • -z9-18 bigr.tif tiles
  • if the above command gives a 'NODATA_VALUES' error then see here.
  • above command creates the tiles for zoom levels 9 to 18. I chose 9 as the starting point as that was the level at which one tile covered the whole 30 km x 30 km area I was interested in, and I used 18 for the 2m and 1m resolution data and 19 for the 50cm and 25cm data. It is quite possible that 17 would have been sufficient for the 2m and 1m data.
  • this creates lots of tiles - for the 25cm data I think it was about 600,000 tiles for z9 to z19, and in my case that was over 5.5GB so you'll need somewhere to host these and the patience to upload them (as I type there is probably just under 2 days left of uploading the z19 tiles for the 25cm data).

The finished tiles can be used in JOSM or P2 (possibly iD but I've not checked) as tms tilesets{zoom}/{x}/{-y}.png{zoom}/{x}/{-y}.png{zoom}/{x}/{-y}.png{zoom}/{x}/{-y}.png

and I added a Leaflet map so I could view them easily.