nsw_dems
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
nsw_dems [2021/05/04 18:25] – [Pre-processing data] bushwalking | nsw_dems [2023/10/08 21:46] – bushwalking | ||
---|---|---|---|
Line 27: | Line 27: | ||
|8827_braidwood|8927_ulladulla|9027_jervis_bay| | | | | | |8827_braidwood|8927_ulladulla|9027_jervis_bay| | | | | | ||
- | ===== Pre-processing data ===== | ||
- | The following may be useful for Windows users. | ||
- | |||
- | Below is a Windows Powershell script that will | ||
- | * move any old DEMs and DEMs from a different zone (you can't mix zones in a virtual raster) to an //archive// sub-folder | ||
- | * extract the raw files from the remaining zip files | ||
- | * convert all of the .ASC files to GeoTIFF | ||
- | * move the old zip files to a //current// sub-folder | ||
- | * zip the //current// and //archive// sub-folders to // | ||
- | * create a virtual raster (.vrt) file of all of the GeoTiffs | ||
- | |||
- | You will need to replace the Environment variables (Path, GDAL_PATH, GDAL_DRIVER_PATH, | ||
- | |||
- | Usage is: | ||
- | < | ||
- | eg < | ||
- | |||
- | The .\ is required if you are running the script from your current directory. | ||
- | |||
- | <file powershell buildvrt.ps1> | ||
- | $zipFile=$args[0] | ||
- | $targetFolder=$args[1] | ||
- | |||
- | # Unzip files from all subdirectories to new folder | ||
- | Expand-Archive -LiteralPath $zipFile -DestinationPath $targetFolder | ||
- | Get-ChildItem -Path " | ||
- | Get-ChildItem -Path $targetFolder -Directory | Remove-Item -Recurse | ||
- | |||
- | # Create hash of zip files, by name (location, date) | ||
- | $zipFileList = @{} | ||
- | Get-ChildItem -Path " | ||
- | $zipFileList.add($_, | ||
- | $_ -match ' | ||
- | $zipFileList[$_][' | ||
- | $zipFileList[$_][' | ||
- | $_ -match ' | ||
- | $zipFileList[$_][' | ||
- | } | ||
- | # $zipFileList | ConvertTo-Json | ||
- | |||
- | # Create hash of location (date, name) | ||
- | $locationList = @{} | ||
- | $zoneCount = @{} | ||
- | $zipFileList.keys | ForEach-Object { | ||
- | if($locationList[$zipFileList[$_][' | ||
- | $t = $locationList[$zipFileList[$_][' | ||
- | $t.add($zipFileList[$_][' | ||
- | } else { | ||
- | $t = @{} | ||
- | $t.add($zipFileList[$_][' | ||
- | $locationList.add($zipFileList[$_][' | ||
- | } | ||
- | if($zoneCount[$zipFileList[$_][' | ||
- | $zoneCount[$zipFileList[$_][' | ||
- | } else { | ||
- | $zoneCount[$zipFileList[$_][' | ||
- | } | ||
- | } | ||
- | # $locationList | ConvertTo-Json | ||
- | # $zoneCount | ConvertTo-Json | ||
- | |||
- | # Create archive folder | ||
- | $archiveFolder = " | ||
- | If(!(test-path $archiveFolder)) | ||
- | { | ||
- | New-Item -ItemType Directory -Force -Path $archiveFolder | ||
- | } | ||
- | |||
- | # Sort each location by date desc, and move old files to /archive | ||
- | $locationList.keys | ForEach-Object { | ||
- | $i=0 | ||
- | $locationList[$_].GetEnumerator() | sort key -des | ForEach-Object { | ||
- | if ($i -eq 0) { | ||
- | $i++ | ||
- | return} | ||
- | else { | ||
- | #$_ | ConvertTo-Json | ||
- | $s = $_.Value | ||
- | Move-Item -Path " | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | # You can't build a VRT with files from a different projection, so | ||
- | # delete files from outside main zone | ||
- | # This could probably be altered to include a step to reproject those files | ||
- | $mainZone = '' | ||
- | $zoneCount.GetEnumerator() | sort value -des | select -first 1 | ForEach-Object { | ||
- | $mainZone = $_.Name | ||
- | } | ||
- | |||
- | $zipFileList.keys | ForEach-Object { | ||
- | if($zipFileList[$_][' | ||
- | Remove-Item -Path " | ||
- | } | ||
- | } | ||
- | |||
- | Get-ChildItem -Path " | ||
- | $Env:Path += "; | ||
- | $Env: | ||
- | $Env: | ||
- | $Env: | ||
- | |||
- | Get-ChildItem -Path " | ||
- | $srcFile = $_.FullName | ||
- | $destFile = $_.FullName -replace ' | ||
- | &" | ||
- | } | ||
- | |||
- | Get-ChildItem -Path " | ||
- | Get-ChildItem -Path " | ||
- | Get-ChildItem -Path " | ||
- | Get-ChildItem -Path " | ||
- | |||
- | # Create current folder | ||
- | $currentFolder = " | ||
- | If(!(test-path $currentFolder)) | ||
- | { | ||
- | New-Item -ItemType Directory -Force -Path $currentFolder | ||
- | } | ||
- | |||
- | # Move zip files to current folder | ||
- | Move-Item -Path " | ||
- | |||
- | # Zip /archive & /current to new zip folder | ||
- | Compress-Archive -Path " | ||
- | |||
- | # Create 2m vrt | ||
- | New-Item " | ||
- | Get-ChildItem -Path " | ||
- | &" | ||
- | </ | ||
- | |||
- | You can rename temp.vrt to anything you like, but it needs to stay relative to the GeoTIFF files. | ||
- | |||
- | It is possible to then build a larger virtual raster from the individual 1:100k virtual rasters. Note that larger rasters need to have the same projection. Also keep in mind that not all data is at 2m resolution. | ||
- | ===== Loading data ===== | ||
- | |||
- | Loading up a large virtual raster into [[https:// | ||
- | * create the boundary of your desired area using the polygon tool at https:// | ||
- | * download the polygon using the **Export drawn data to GeoJSON** function | ||
- | * load up the Python console (// | ||
- | * run the following command (replace file locations with your own - the INPUT should be your virtual raster, and the MASK should be your GeoJSON boundary polygon) | ||
- | |||
- | < | ||
- | resultClip = processing.runAndLoadResults(" | ||
- | </ |
nsw_dems.txt · Last modified: 2023/11/23 15:01 by bushwalking