User Tools

Site Tools


tiling_etopos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tiling_etopos [2023/07/07 18:40] – created bushwalkingtiling_etopos [2023/07/08 09:52] (current) bushwalking
Line 12: Line 12:
  
 First step is to strip off the border of the PDF and convert to a raster format. We can do this for a single image using gdalwarp, by setting a few options, including: First step is to strip off the border of the PDF and convert to a raster format. We can do this for a single image using gdalwarp, by setting a few options, including:
--  * t_srs <target spatial reference> - I've used EPSG:28356, which is MGA94 Zone 56 (eastern NSW). All maps need to be in the same co-ordinate system in order to merge them in the next step.+  -t_srs <target spatial reference> - I've used EPSG:28356, which is MGA94 Zone 56 (eastern NSW). All maps need to be in the same co-ordinate system in order to merge them in the next step.
   * -r <resampling_method> - cubic seems to be the recommended option given that we aren't trying to resize   * -r <resampling_method> - cubic seems to be the recommended option given that we aren't trying to resize
   * -cutline - applies a mask to the raster (confusingly, this doesn't actually crop the image - you also need "crop_to_cutline")   * -cutline - applies a mask to the raster (confusingly, this doesn't actually crop the image - you also need "crop_to_cutline")
Line 21: Line 21:
 Sample command in full - you'll need to set your own directories, both for input and output file, and for the location of the NSW map boundaries GeoJSON: Sample command in full - you'll need to set your own directories, both for input and output file, and for the location of the NSW map boundaries GeoJSON:
  
-<code>gdalwarp -t_srs EPSG:28356 -r cubic -cutline "E:\data\maps\nsw_map_boundaries\20160506_nsw_map_bounds.geojson" -cwhere "name = '9030-4S SPRINGWOOD'" -crop_to_cutline -dstalpha "E:\data\maps\maps\nsw\2023\9030-4S SPRINGWOOD.pdf" "E:\data\maps\maps\nsw\9030-4S SPRINGWOOD.tif"</code>+<code>gdalwarp -t_srs EPSG:28356 -r cubic -cutline "E:\data\maps\nsw_map_boundaries\20160506_nsw_map_bounds.geojson" -cwhere "name = '9030-4S SPRINGWOOD'" -crop_to_cutline -dstalpha "E:\data\maps\maps\nsw\9030-4S SPRINGWOOD.pdf" "E:\data\maps\maps\nsw\9030-4S SPRINGWOOD.tif"</code>
  
 Unfortunately this approach turns a 10MB PDF into a 70MB GeoTiff!  Unfortunately this approach turns a 10MB PDF into a 70MB GeoTiff! 
  
 You can batch automate the conversion of these in Windows by running a Powershell command eg You can batch automate the conversion of these in Windows by running a Powershell command eg
-<code>Get-ChildItem -Path "E:\data\maps\maps\nsw\2023\*.pdf" | ForEach-Object {+<code>Get-ChildItem -Path "E:\data\maps\maps\nsw\*.pdf" | ForEach-Object {
  $srcFile = $_.FullName  $srcFile = $_.FullName
  $destFile = $_.FullName -replace '.pdf', '.tif'  $destFile = $_.FullName -replace '.pdf', '.tif'
Line 35: Line 35:
  
 You now have a directory of GeoTiffs. In Windows, you can run the following at the command line to create a list of all the files in a text document: You now have a directory of GeoTiffs. In Windows, you can run the following at the command line to create a list of all the files in a text document:
-<code>dir /b /s "E:\data\maps\maps\nsw\test\*.tif" > "E:\data\maps\maps\nsw\test\tiff_list.txt"</code>+<code>dir /b /s "E:\data\maps\maps\nsw\*.tif" > "E:\data\maps\maps\nsw\tiff_list.txt"</code>
  
 Finally, you can run gdal_merge, using the list from the previous step to create one huge GeoTiff. Note that normal GeoTiffs max out at 4GB, so you need to be selective about how many files you include in the merge. If you try to include too many, you will get errors, and a partially completed output. I got away with 56 1:25k maps, but the actual number will depend on various factors. There is a BIGTIFF=YES option that can be added to the -co option, but I don't know how this works in downstream processes/systems. Finally, you can run gdal_merge, using the list from the previous step to create one huge GeoTiff. Note that normal GeoTiffs max out at 4GB, so you need to be selective about how many files you include in the merge. If you try to include too many, you will get errors, and a partially completed output. I got away with 56 1:25k maps, but the actual number will depend on various factors. There is a BIGTIFF=YES option that can be added to the -co option, but I don't know how this works in downstream processes/systems.
  
-<code>gdal_merge -o "E:\data\maps\maps\nsw\2023\sydney_basin.tif" -of GTiff -co COMPRESS=LZW --optfile "E:\data\maps\maps\nsw\test\tiff_list.txt"</code>+<code>gdal_merge -o "E:\data\maps\maps\nsw\sydney_basin.tif" -of GTiff -co COMPRESS=LZW --optfile "E:\data\maps\maps\nsw\tiff_list.txt"</code>
  
 For OziExplorer, the TIF can be used directly (use File->Import Map->Single DRG Map - and you will need the GeoTiff support library DLL), but it is faster and more space-efficient if converted to OZFX4 format. This can be done using Img2Ozf, downloadable from the OziExplorer website. Default settings are reasonable. As an example, a 4GB GeoTiff was converted to a 400MB OZFX4 file - a 90% reduction in size. For OziExplorer, the TIF can be used directly (use File->Import Map->Single DRG Map - and you will need the GeoTiff support library DLL), but it is faster and more space-efficient if converted to OZFX4 format. This can be done using Img2Ozf, downloadable from the OziExplorer website. Default settings are reasonable. As an example, a 4GB GeoTiff was converted to a 400MB OZFX4 file - a 90% reduction in size.
tiling_etopos.1688719243.txt.gz · Last modified: 2023/07/07 18:40 by bushwalking

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki