crazed monkey

Archive for the 'googletilecutter' category

RSS

Google Maps tile cutter on Google code

I’ve recently created a project for my command-line image tiler for Google Maps on Google Code. Coincidentally, the official Google Maps API blog linked to my tool on Monday so hopefully there will be some interest in playing around with it.

Posted on September 12th, 2007 in googletilecutter - No Comments »

Unix command-line tile cutter for Google Maps

When I released my new Toronto transit map I promised to release some of the tools I used to create it. Possibly the most useful tool I created is my command-line tile cutter. True, there are other image tilers, such as a Photoshop script and a web-based tool which uses Google Maps. I don’t have Photoshop and find it slow, and the web-based tool is difficult to use even with small files, so I created my own tile cutter.

My image tiler uses Free Software, is released under the GPL, and has the following features:

  • Tiles most image formats, including GIF, JPEG, PNG and TIFF.
  • Works on most flavours of Unix, including Mac OS X.
  • Supports version 1 and version 2 zoom levels.
  • Automatically calculates offsets for all zoom levels.
  • Supports padding from the upper-left as output by the web-based tiling helper.
  • Automatically pads image to size appropriate to Google Maps (ie. multiple of 256).
  • Optionally discards empty transparent tiles to save space.
  • Optional prefix for each tile.
  • Outputs tiles in PNG format.
  • Compresses tiles with either advpng or pngcrush.

The tiler requires ImageMagick and advpng or pngcrush for PNG compression. (I recommend advpng as it is faster and compresses smaller in most situations.) Tiled image size is restricted only by disk space and ImageMagick limitations.

To use the tile cutter, one need only specify the image being tiled, the Google tile coordinates of the top-left tile, the zoom level for which those coordinates are valid and the zoom level the tile represents. For example, suppose we have three images (img15.png, img16.png and img17.png) for zoom levels 15 through 17 (in version 2 zoom levels), respectively. The top-left corner of the image at level 15 is 1812,1924. You would then run the following commands to generate the tiles:

% googletilecutter -o 15 -t 1812,1924 -z 15 img15.png
% googletilecutter -o 15 -t 1812,1924 -z 16 img16.png
% googletilecutter -o 15 -t 1812,1924 -z 17 img17.png

Note that the only options which need to be changed from image to image are the zoom level of the image and the image itself. Compression and discarding of empty tiles is performed automatically. For more command-line options execute the script with the -h option.

Download the Unix command-line tile cutter for Google Maps. If you have any problems or experience any unexpected behaviour, please leave a comment below.

Posted on January 24th, 2007 in googletilecutter, programming - 33 Comments »