Geographical data visualization with Autark Map
Draw 2D and 3D urban layers with WebGPU. This chapter uses local data and an optional Overpass request; no tile server or backend is required.
autk-map is the rendering module of Autark. This page goes from an empty canvas to an interactive map and covers the main things the module offers: layers, OpenStreetMap data, rasters, thematic color and picking. The module does not care where a GeoJSON FeatureCollection comes from. When you combine it with autk-db, autk-compute and autk-plot, every call you learn here stays the same; only the origin of the data changes.
WebGPU check
navigator.gpu is the entry point of the WebGPU API. When it is missing, the browser does not implement WebGPU and autk-map cannot run. navigator.gpu.requestAdapter() asks for an adapter, a handle to one physical GPU (or a software fallback). It can resolve to null even when the API exists, typically because hardware acceleration is off. The next step, adapter.requestDevice(), gives the device that allocates buffers and submits work; map.init() does that for you.
Data
The examples use three datasets of Manhattan, bundled inside tutorial/data/: the neighborhood polygons, a CSV of noise complaints with latitude and longitude, and OpenStreetMap roads and buildings. Load the first two once; later cells reuse them.
1. The lifecycle of a map
A simple vector map follows these steps:
- Put a
<canvas>on the page. new AutkMap(canvas)creates the map controller: renderer, camera, layer manager, events and a small built-in UI.await map.init()acquires the WebGPU device and sizes everything to the canvas.map.loadCollection(id, {collection, sourceCrs})turns aFeatureCollectioninto a GPU layer. Call it once per layer.map.fitBounds()frames the first layer. Loading a layer sets the scene origin but does not fit its extent.map.draw()starts rendering. By default the map draws once and then only when something changes.
Use the map with the mouse:
| Input | Effect |
|---|---|
| Drag | Pan |
| Shift + drag | Rotate and tilt |
| Mouse wheel or pinch | Zoom around the pointer |
| Double-click | Pick a feature, once picking is enabled on a layer (Section 6) |
s | Cycle through the built-in base styles |
r | Reset the camera |
The button in the top-left corner of the map opens the built-in layer menu. Each layer has three toggles: visibility, thematic coloring and picking. Everything the menu does is also available from code, which is what the rest of the page is about. The map object is a plain value, so any later cell can inspect it, for example its visible 2D layers in draw order, bottom first:
2. Layers
A layer is a GeoJSON collection plus a type that tells the renderer how to draw it:
map.loadCollection(layerId, {collection, sourceCrs, type, property, loadConfig})
layerIdis a unique string. Every later update (style, thematic data, picking, removal) addresses the layer by this id.collectionis theFeatureCollection;sourceCrsdeclares the input CRS if it differs from the map’s CRS.typeis optional for plain vector data and is inferred from the geometry. Physical types are never inferred; you ask for them.propertyis required for rasters and optional otherwise (Sections 4 and 5).loadConfigholds geometry options applied while the mesh is built, such asbuildingsZeroHeight.
| Type | Geometry | Notes |
|---|---|---|
surface, parks, water | polygons | physical layers that build the base map |
roads | lines | physical; width follows the OSM highway tag |
buildings | polygons | physical; extruded in 3D |
points, polylines, polygons | matching geometry | generic layers for your own data; inferred when type is omitted |
raster | grid | needs property (Section 4) |
Stacking. Layers have a default draw order. Use setLayerOrder() to restack visible 2D layers, bottom first. Buildings are drawn separately in 3D. In the cell below, try reversing the order of the neighborhood polygons and noise points.
3. Connecting OSM layers
Autark also supports OpenStreetMap natively. autk-db fetches the data for an area and builds the base layers of a city map: surface, parks, water, roads and buildings. Under the hood it queries the Overpass API and converts the answer into the feature-centric model, so every building, street or park becomes a feature of a FeatureCollection, exactly like the ones loaded from files. That is what makes the two sources interchangeable: the map does not care whether a collection came from OSM or from a file, and both are loaded with the same loadCollection() call.
The loop below is the usual pattern. getLayersMetadata() lists the layers in the database with their names and types, and each one goes to the map under that type.
4. Raster layers
Raster layers represent gridded data such as temperature or density. autk-map renders a raster layer from a FeatureCollection whose cell values are stored in feature properties, together with a property path that tells the renderer which band to read. GeoTIFF files can be loaded with autk-db, and so can the heatmaps it builds with buildHeatmap().
The example counts noise events within 700 projected meters of each grid cell and smooths the resulting band before rendering. Use getRaster() to read the band and setLayerOrder() to choose what appears above it. A PERCENTILE color domain keeps extreme values from dominating the display.
5. Thematic data
Thematic rendering maps a feature attribute to color. The attribute does not have to live on the feature itself: autk-map treats any value reachable through a property path as thematic input. It can be an intrinsic attribute of the geometry, or urban data that has been projected onto the feature, for instance by a spatial join in autk-db or a computation in autk-compute.
The workflow has four steps:
- Load the layer with
loadCollection(). - Configure the color map with
updateColorMap(). - Point to the source property with
updateThematic(). - Turn thematic display on with
isColorMapinupdateRenderInfo().
5.1 Categorical attributes
Categorical palettes assign one color per class; use them for labels such as road types. It helps to first fold the raw values into a small, ordered set of groups so the palette domain stays stable. Here the roads of the OSM base map are grouped into primary, secondary and other under properties.compute.highwayGroup, and the USER domain fixes the order of the classes.
5.2 Ordered numeric attributes
A sequential palette suits positive values such as area. A diverging palette is more useful when a midpoint has meaning, for example zero change. Here the PERCENTILE domain limits the effect of outliers. Convert the source shape_area strings to numbers without modifying the collection shared by other cells.
5.3 Spatial joins
A spatial join attaches an aggregate from a second table to each feature of a base layer. A common use is counting point events, such as noise complaints, inside a buffer around each polygon or line. The cell below joins the noise events to the OSM buildings of the area, counting events within 1000 m of each building. The result is stored under properties.sjoin.count.noise, a property path autk-map reads directly, so the buildings are colored by the number of nearby complaints.
6. Interactions
autk-map exposes three complementary interaction mechanisms. They share the same render-info flags and the same event bus, so they can be combined in any order:
- Picking: pointer-driven selection that emits events through
map.events.on(). - Programmatic highlight and skip: direct control over which components stand out (
setSelection()) or are hidden (setSkipped()). - Layer visibility: show, hide or fully remove a layer (
isSkipinupdateRenderInfo(),removeLayer()).
In Autark 5, isClick enables selection on double-click (MapEvent.CLICK) and isHover enables a separate, transient highlight (MapEvent.HOVER). Hover over a neighborhood to see its name, then double-click and move away: the selected neighborhood stays highlighted. The event’s selection contains indices in the source collection, the same convention used by autk-plot.
map.style.setPredefinedStyle() accepts default, light, dark, google, apple, and osm. The s key cycles the built-in styles. To go beyond vector and analytical raster layers, see the User Guide chapters on imagery and basemaps and terrain.
7. Draw named regions and flows
The native editor is independent of ordinary feature-index selection. Enable it through per-element UI configuration, create a named group, and choose Polygon or Rectangle. Move, Undo, Delete, and Flow Arrow edit the geographic selection; MapEvent.NAMED_SELECTION reports changes.
Regions use WGS84 longitude/latitude even though the map renders in a projected workspace. Feature places use semantic string/number IDs, not the collection indices of click events. These places can be compiled by selectionSql(), as in the database chapter. showUi objects disable omitted keys; updateUi({legend: true}) patches only that key. uiConfig reports all resolved flags.
For custom controls use the lower-level RegionDrawer and its REGION/ARROW events. screenToLonLat() uses CSS pixels relative to the canvas; projection can return null above the horizon. Map destruction removes attached drawing tools. Invalid explicit load/update calls throw synchronously while preserving previous state; missing-layer removal and repeated destruction remain safe no-ops. See Selections and region editing.
Credits
Adapted from the Observable notebook 04. Geographical Data Visualization, produced for the tutorial Urban Data Analytics with Autark at SIBGRAPI 2026. See the author list. The original used prepared, projected data files that are not public; this version uses Manhattan neighborhoods and noise events from the repository and OpenStreetMap through autk-db.