Skip to content

Instantly share code, notes, and snippets.

@aaronblondeau
Created June 3, 2025 23:16
Show Gist options
  • Save aaronblondeau/20efcaffb0d799c0f191de68952d609c to your computer and use it in GitHub Desktop.
Save aaronblondeau/20efcaffb0d799c0f191de68952d609c to your computer and use it in GitHub Desktop.
Example Tilemaker process file.
-- Based on process-example.lua
-- Assign nodes to a layer, and set attributes, based on OSM tags
function node_function(node)
-- POIs go to a "poi" layer (we just look for amenity and shop here)
local amenity = Find("amenity")
local shop = Find("shop")
if amenity~="" or shop~="" then
Layer("poi")
if amenity~="" then Attribute("class",amenity)
else Attribute("class",shop) end
Attribute("name", Find("name"))
AttributeNumeric("rank", 3)
end
-- Places go to a "place" layer
local place = Find("place")
if place~="" then
Layer("place")
Attribute("class", place)
Attribute("name", Find("name"))
if place=="city" then
AttributeNumeric("rank", 4)
MinZoom(3)
elseif place=="town" then
AttributeNumeric("rank", 6)
MinZoom(6)
else
AttributeNumeric("rank", 9)
MinZoom(10)
end
end
-- Include peaks
local natural = Find("natural")
if natural == "peak" or natural == "volcano" then
Layer("place", false)
Attribute("class", natural)
local ele = Find("ele")
if ele ~= "" then
local meter = math.floor(tonumber(ele) or 0)
local feet = math.floor(meter * 3.2808399)
AttributeNumeric("ele", meter)
AttributeNumeric("ele_ft", feet)
end
Attribute("name", Find("name"))
end
end
-- Assign ways to a layer, and set attributes, based on OSM tags
function way_function()
local highway = Find("highway")
local waterway = Find("waterway")
local building = Find("building")
-- Trails
if highway=="path" then
Layer("trail", false)
MinZoom(6)
-- Retain common trail osm tags
Attribute("bicycle", Find("bicycle"))
Attribute("foot", Find("foot"))
Attribute("horse", Find("horse"))
Attribute("surface", Find("surface"))
Attribute("sac_scale", Find("sac_scale"))
Attribute("mtb:scale:imba", Find("mtb:scale:imba"))
Attribute("osm_id", Id())
Attribute("name", Find("name"))
elseif highway=="footway" and Find("footway")=="sidewalk" then
-- silently ignore sidewalks
return
elseif highway=="footway" and Find("footway")=="crossing" then
-- silently ignore street crossings
return
-- Roads
elseif highway~="" then
Layer("transportation", false)
if highway=="unclassified" or highway=="residential" then highway="minor" end
Attribute("class", highway)
Attribute("name", Find("name"))
elseif waterway=="canal" and Find("nhd:ftype")=="CanalDitch" then
-- silently ignore ditches
return
elseif waterway=="stream" or waterway=="river" or waterway=="canal" then
-- Rivers
-- discard intermittent waterways (to reduce file size)
if Find("intermittent")~="yes" then
Layer("waterway", false)
Attribute("class", waterway)
AttributeNumeric("intermittent", 0)
Attribute("name", Find("name"))
end
-- Lakes and other water polygons
elseif Find("natural")=="water" then
Layer("water", true)
if Find("water")=="river" then
Attribute("class", "river")
else
Attribute("class", "lake")
end
Attribute("name", Find("name"))
end
-- We could also add things like grass, scrub, wood
-- https://www.openstreetmap.org/way/421699900#map=17/38.524876/-106.028020
-- https://www.openstreetmap.org/way/501069060#map=14/38.54088/-105.98538
-- https://www.openstreetmap.org/way/501071079
end
-- National Forests and Parks (these are relations)
-- San isabel : https://www.openstreetmap.org/relation/396343#map=8/38.309/-105.744
-- Sand dunes wildeness : https://www.openstreetmap.org/relation/16848699#map=12/37.7661/-105.5755
-- Browns canyon : https://www.openstreetmap.org/relation/5916900#map=13/38.70125/-106.04213
function relation_scan_function()
local boundary = Find("boundary")
local leisure = Find("leisure")
if boundary=="national_park" or boundary=="protected_area" or leisure=="nature_reserve" then
Accept()
end
end
function relation_function()
local boundary = Find("boundary")
local leisure = Find("leisure")
if boundary=="national_park" or boundary=="protected_area" then
Layer("park",true)
Attribute("class",boundary)
Attribute("name", Find("name"))
elseif leisure=="nature_reserve" then
Layer("park",true)
Attribute("class",leisure )
Attribute("name", Find("name"))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment