Command line tool to generate point labels from GeoJSON polygons.
Features include:
--collections=explode
), only the largest part (--collections=largest
), or treat all parts as one (--collections=combine
)_area
property (in m²) (--include-area
)_bbox
property ([west, south, east, north]
) (--include-bbox
)tippecanoe
minzoom to each label (--include-minzoom
)npm install --global geojson-polygon-labels
geojson-polygon-labels [--polylabel-precision=0.001] [--coordinate-precision=5] [--include-area] [--include-bbox] [--method=polylabel] [--collections=explode] [--include-minzoom=0-16] [--verbose] layer.geojson > labels.geojson
--polylabel-precision
Polylabel precision. Defaults to 0.000001
.--coordinate-precision
Output coordinate precision. Defaults to 5
.--method
Label placement algorithm. Options are polylabel
, centroid
, center-of-mass
, center-mean
, center-median
, centroid
, point-in-polygon
.--include-area
Adds an _area
property in m².--include-bbox
Adds a _bbox
property as [west, south, east, north]
--include-minzoom
will try to determine a suitable minzoom for the label to appear at and save it in the tippecanoe
key for use in tippecanoe. Value in the form min-max where min is the smallest minzoom and max the largest minzoom.--collections
How to place labels for GeometryCollections or Multi* Geometry types. Options are explode
, largest
, combine
.--input-format
Input format. Options are geojson
, geojsonseq
.--output-format
Output format. Options are geojson
, geojsonseq
.