Convert KML/KMZ to Purple Pen

Select Course KML file: (MapRun KML course file with placemarks, eg from GE or OOM)
Select Map KML file: ("doc.kml" file extracted & renamed from KMZ map file)
Specify Map filename: ("files/tile_0_0.jpg" file extracted & renamed from the KMZ map file)
Specify Map Dimensions & Scale: x pixels by y pixels at dpi
Select map scale:
Select course kind:

This script converts a MapRun Course KML file and associated untiled KMZ file contents to a skeletal Purple Pen (PPEN) file. It assumes the KML course file is structured as a document for the event, which contains a folder that contains the course placemarks, as is created by OOM, or following my notes on MapRun course creation. It will not work correctly without this structure.

You need to extract the map KML "doc.kml" and JPG image "files/tile_0_0.jpg" files out of the map KMZ file (which is just a zip archive, most unzip tools can be used) and rename appropriately. You also need to analyse the image to determine its size in pixels (any image viewing program should give this), and know the dpi resolution of the image.

You may want to first edit the PPEN file with a text editor, with care, to correct any incorrect attribute guesses, or event title. You will then need to open and edit the resulting file using Purple Pen to add and save additional required items. You will need to set the print page size and area, customise course appearance, and add any additional text or images.

Note that the orientation of the map in the PPEN file depends on its orientation in the KMZ file. KMZ's from the OOM website, and from OCAD seem to work fine. However the OO Mapper program generates KMZ images aligned on true north, irrespective of the underlying map orientation, and hence the resulting PPEN file is usually not satisfactory.

Yes this is a bit messy, but its what I have for now.

Warning:At present this script is under development, experimental, and only a minimal conversion is done. It will likely fail if the supplied input files are not formatted as expected.
Warning: Currently only working for images aligned on true north, calculations for rotated images still being worked on!!!!


kml2ppen.php v1.0 - Copyright © Lawrie Brown Nov 2021 with Creative Commons BY-NC-SA 4.0 licence.
Please send any comments, suggestions for improvements, or other feedback to: Lawrie.Brown@canb.auug.org.au
[Back to Orienteering Resources]