wiki:PythonScripts

Version 3 (modified by Uriel, 7 years ago) (diff)

--

There are a few main python scripts created to help perform various tasks with Maperitive, which are described here. There are also a number of "test scripts" which are one-offs or works in progress stored on the maps USB drive.

convert_georef.py

This script is used to read in a directory of images (such as created by the Maperitive export-bitmap or save-source command), and convert all the Maperitive .georef text files in that folder to GDAL-compatible world files. The folder to be worked on must be manually entered at the top of the python script by editing the file.

Example:

Matperitive .georef

<georef>
  <srs>
    <id>EPSG:3857</id>
  </srs>
  <origin>
    <x>-20037508.342789244</x>
    <y>-7558415.6560817827</y>
  </origin>
  <cell-width>61.844161551818772</cell-width>
  <cell-height>105.31808356728818</cell-height>
</georef>

World File (.pngw)

61.844161551818772
0
0
105.31808356728818
-20037508.342789244
-7558415.6560817827

fill_terrain_tiles.py

The NASA SRTM dataset does not include areas of the earth containing no height data (ie: the ocean). However, Maperitive is dumb about what to do if it tries to get SRTM data for an ocean and none exists, and it will fail. This script fills in the SRTM data by generating blank files to fill in the gaps. SRTM files are named for their latitude and longitude (ex: 32N042W.hgt), so the file iterates through all possible images and when a file is missing, creates it.

This python script can be run on the command line and passed command line options. Run {{python fill_terrain_tiles.py -h}} to see these options.

This command has already been run on the USB drive, to create the SRTMGL1_full and SRTMGL3_full folders. These folders are linked in the Maperitive cache folder using directory softlinks.

gen_terrain_image_script.py

gen_tiles_from_images_script.py

gen_terrain_tiles_script.py

Attachments (5)

Download all attachments as: .zip