Analysis

Builds a new layer from one or two existing layers.

type: geoprocessingtoolbarstable

What it does

Analysis builds a new layer from one or two existing layers.

Available: clip, erase, intersect, union, select by location, spatial join, dissolve, centroid, convex hull, simplify, buffer, voronoi, delaunay, and cartogram. Plus statistics, which is a dissolve without the geometry.

Pick an operation, choose the input layers, set the options, and calculate. The result is added to the map as a new layer.

Worth knowing before you start:

Everything runs inside your browser, using GDAL compiled to WebAssembly. Your data is not uploaded anywhere.

Using it

  1. Choose an operation. Its inputs and settings appear below it.
  2. Pick the layers, set the values, press Calculate.
  3. The result is added as a new layer, and the panel reports how many features it used.

Only loaded data is used. A GeoJSON layer gives every feature. A tiled layer gives only the features in view. The panel warns you on inputs where that can change the result.

Three example pages show the operations on real data:

A long calculation can be canceled.

In your own map

Add geoprocessing to a toolbar. It appears as Analysis and works on whatever layers are on the map.

The WebAssembly is only fetched when it is needed, so a visitor who never opens the panel never downloads it. Opening the panel starts that download in the background while you fill in the form.

Extending it

An operation is one registry entry: inputs, parameters, a diagram, and either an SQL template or a JavaScript function.

Operations run in EPSG:3857 instead of longitude/latitude because SpatiaLite works on a flat plane. Inputs are written into one indexed SpatiaLite database before the query runs. Keep the index: on 144×576 polygons it took a query from 19.8 s to 1.3 s without changing the algorithm.

Union is the slow operation to watch when testing performance. On 257 countries against 4000 regions, clip took 4 s, intersect 5 s, and union 38 s.

Config typegeoprocessing
Element<webmapx-geoprocessing-tool>
Placementtoolbar
Sourcesrc/components/webmapx-geoprocessing-tool.ts
src/utils/geoprocessing-operations.ts
src/workers/geoprocessing-runner.ts
Teststests/geoprocessing.test.ts
Relatedbuffer, cartogram, layerOverview