Maperitive

CalvinNg4 1,421 views 41 slides Oct 23, 2013
Slide 1
Slide 1 of 41
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41

About This Presentation

Presentation slides on creating custom map tiles for bounded areas with Maperitive.


Slide Content

MAPERITIVE
CREATING CUSTOM MAP TILES FOR
BOUNDED AREAS
by Calvin Ng / @calvinnwq

BACKGROUND
I've created an app which utilises
to retrieve real time tweets with geolocation and plot them
onto a map using .
Twitter's Streaming API
leaflet.js
...
Then came the requirement
...
CUSTOM DESIGNED MAP

WHAT NEXT?
Having no clue, I did what any of you would
...
GOOGLE

MAPERITIVE
This presentation will go through the solution I stuck with
after a couple others that I've tried
...
SO LET'S BEGIN!

1. MAPERITIVE
“Maperitive is a FREE desktop application for drawing maps
based on OpenStreetMap and GPS data. You can define what
gets on the map and how it is painted. You can also export
these maps into bitmaps and SVG files and print them.”

SYSTEM REQUIREMENTS
Windows: XP SP3 or later with installed.
Linux & Mac: latest installed.
Microsoft.NET 4
Mono

WHAT CAN I DO WITH MAPERITIVE?
Make maps with custom content and style
Render relief contours, hillshading,
Exporting maps to bitmaps or SVG files
Make map tiles for the web
Automating mapmaking through scripts, Python and
Maperitive command-line console
hypsometric tinting

MAPERITIVE LINKS
Download Link
Ten Minute Intro
Maperitive Documentation

2. STARTING UP MAPERITIVE
OPENING UP MAPERITIVE ON WINDOWS / MAC / LINUX

WINDOWS
Ensure XP SP3 or later with Microsoft.NET 4 installed and
simply run Maperitive.exe

MAC / LINUX
Ensure is installed and assuming Maperitive is
extracted to Desktop, run the following:
Mono
$ sh ~/Desktop/Maperitive/Maperitive.sh

SCREENSHOT

INTERFACE

3. GEO BOUNDING BOX
RETRIEVING GEO COORDINATES AND SETTING UP GEO BOUNDS

CONSIDERATIONS?
Are there any specific countries? (e.g. Singapore)
What are the zoom levels to consider?
Is the map fixed or interactive?

ONLINE TOOLS
1.
2. by
OpenStreetMap
Bounding BoxKlokan Technologies

BOUNDING BOX
Select an area and select "CSV" as type of data

4. EXPORTING BITMAP
EXPORTING PNG FOR CUSTOM DESIGNING

SETTING BOUNDING BOX
set-geo-bounds 103.406067,1.090327,104.246521,1.607913

ZOOM TO BOUNDS
zoom-bounds

EXPORT BITMAP
export-bitmap zoom=12

EXPORT BITMAP
2 files will be generated in output folder:
output.png
output.png.georef (required for later steps)

5. EDITING CUSTOM MAP
DESIGNING OF CUSTOM MAP AND CONSTRAINTS

CONSTRAINTS?
output.png should be the template to work upon.
Custom designed map (let's call it map.png) should retain
exact dimensions as output.png
Multiple layers to show terrain / roads / etc.?

SAMPLE CUSTOM MAP
For the sake of this presentation, here is a sample map I've
made which I will name map.png

6. LOADING CUSTOM MAP
LOAD CUSTOM EDITED MAP IN MAPERITIVE

CUSTOM MAP FILES
Using map.png from our previous example, we will also
need to create a copy of output.png.georef and rename that
to map.png.georef

LOAD IMAGE IN MAPERITIVE
Assuming we put map.png and map.png.georef back into the
output folder:
load-image file=output/map.png background=false

DISABLE OTHER MAPS
You can choose to disable underlying maps like the default
Web map (OSM Mapnik) so they don't get generated by
simply clicking on the yellow star under the Map Sources at
the bottom right

7. GENERATE TILES
GENERATING TILES FOR SPECIFIC ZOOM LEVELS

GENERATE TILES
For this example we will generate tiles for 2 zoom levels (11
& 12) for the bounding box we have.
generate-tiles minzoom=11 maxzoom=12 bounds=103.406067,1.090327,104.246521,1.607913
Generated tiles can be found in the Tiles folder

TILES FOLDER

8. MAP TILES
HOW TO USE THEM

HOSTING THEM
Copy the folders to your project directory. In the example to
follow, I've placed them in my assets folder of this
presentation with path assets/tiles/

REFERENCING THEM IN CODE
Referencing them is as simple as using the following URL:
var tile_url =
"http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png";

EXAMPLE CODE
In this example, I will make use of .leaflet.js
// create bounds
var bounds = new L.LatLngBounds(
new L.LatLng(1.090327, 103.406067)
, new L.LatLng(1.607913, 104.246521)
);
// create a map in the "map" div, set the view to a given place and zoom
var map = L.map('map', {
"center" : [1.335, 103.820]
, "zoom" : 11
, "minZoom" : 11
, "maxZoom" : 12
, "maxBounds" : bounds
});
// add an OpenStreetMap tile layer
L.tileLayer('http://calvinnwq.github.io/maperitive-presentation/assets/tiles/{z}/{x}/{y}.png'
attribution: "Calvin's custom map design"
, minZoom: 11
, maxZoom: 12
}).addTo(map);

EXAMPLE RESULT
Run it!

SUMMARY
WHAT DID WE LEARN TODAY?

MAPERITIVE SUMMARY
What Maperitive is
Starting up Maperitive

STEPS SUMMARY
1.
2.
3.
4.
5.
Obtaining geo bounding box
Exporting bitmap
Editing custom maps
Loading custom maps in Maperitive
Generating map tiles

FIN ~
Thank you for your attention