Page 1 of 1

Tool for downloading and splitting topo maps across A3 pages

PostPosted: Wed 15 Jan, 2025 11:44 pm
by tschanzer
I recently found myself needing a printed NSW Spatial Services topo map, but had neither the time to buy a hard copy nor access to a large-format printer to produce my own. I needed to split the map across several A3 pages for use with a normal printer, but found Adobe Acrobat's poster print option too restrictive.

So I wrote a simple Python-based command-line tool that will, given the name of any 1:25k map (e.g., "katoomba") and publication year (e.g., 2017):
  • Download the corresponding PDF from the NSW Spatial Collaboration Portal
  • Split the map (excluding legend and cover page) across six landscape A3 pages with 20mm overlaps
  • Put the legend and cover page side-by-side on a separate portrait A3 page

For example, the command
Code: Select all
python -m nsw_topo_split katoomba 2022
produces (in 1.5s on my cheap laptop) pages that look like this:
example.png


The source code, installation instructions and more detailed documentation can be found at https://github.com/tschanzer/nsw-topo-split; you are free to use, modify and redistribute them under the terms of the MIT license. Any feedback is welcome, but I can't commit to actively maintaining the package.

Re: Tool for downloading and splitting topo maps across A3 p

PostPosted: Fri 17 Jan, 2025 10:59 am
by Allchin09
Nice work! Thanks for sharing.

I tried it on the Katoomba 2022 per your example and I was surprised to see roads, etc outside of the border/collar but I assumed it was some layer issue with how you'd processed the map. Looked at the original and it's the same though so not your issue

I noticed that all three produced files (original, _cover and _split) are the same size. I wouldn't expect the cover to be 10mb. Split maybe. Just seemed odd.

Also - maybe an option for those with only an A4 printer? Anyway, I'll check out your code :)

Re: Tool for downloading and splitting topo maps across A3 p

PostPosted: Fri 17 Jan, 2025 12:51 pm
by tschanzer
Thanks for the feedback!
Allchin09 wrote:I noticed that all three produced files (original, _cover and _split) are the same size. I wouldn't expect the cover to be 10mb. Split maybe. Just seemed odd.

This is because PDF cropping (in general, not just in pypdf) works by adjusting the page's media box without affecting the underlying data. If the file size of the cover page is an issue, I can think of two ways to delete the cropped data:
  • Rasterise the document
  • In Adobe Acrobat, "Redact a PDF" > "Sanitize document" > Tick "Deleted or cropped content" and "Overlapping objects"
Allchin09 wrote:Also - maybe an option for those with only an A4 printer? Anyway, I'll check out your code :)

Definitely! The code was a bit of a rush job, so the page size and layout are currently hard-coded, but I can easily include them as command-line options.

Re: Tool for downloading and splitting topo maps across A3 p

PostPosted: Tue 21 Jan, 2025 11:25 am
by tom_brennan
Nice one! Would it be worth adding a bit more side-to-side overlap to make more use of the white space.

Though I should probably just fork the code and create a pull request :lol:

Re: Tool for downloading and splitting topo maps across A3 p

PostPosted: Tue 21 Jan, 2025 8:42 pm
by tschanzer
Good idea Tom! The default behaviour is now to automatically increase the horizontal and/or vertical overlaps to eliminate any white space, as shown below. There is a command line flag to disable this.
example.png

Other changes:
  • Added command line options for page size and orientation, number of pages along each axis, and overlap along each axis
  • Output is now sorted into subdirectories by year and map name
  • If the original map already exists, it will not be re-downloaded unless the -f/--force-download flag is given
  • More docstrings and comments

The latest usage instructions are in README.md. Issues and pull requests are most welcome.

Re: Tool for downloading and splitting topo maps across A3 p

PostPosted: Fri 24 Jan, 2025 11:49 am
by Allchin09
Liking the enhancements :) I've raised two issues on github ;)