# mapserver.layer.publish

Publish or update a map layer, by --name, in the project's layer registry

# mapserver.layer.publish

```
mapserver.layer.publish --name TEXT --route TEXT [--from FILE] [--parse geojson|geoparquet] [--bbox-optional] [--max-items N] [--field TEXT…] [--min-zoom N] [--max-zoom N] [--skip-optimize] [--build-artifact] [--fill TEXT] [--stroke TEXT] [--stroke-width N] [--point-radius N] [--point-color TEXT] [--style TEXT] [--filter TEXT] [--function TEXT] [--ttl DURATION] [--store TEXT] → layer
```

Publish or update a map layer, by `--name`, in the project's layer registry. It answers on `/ms/{owner}/{project}/{route}` while the project's `ms` surface is on (off by default; `layer.serving` says which). `--from` is a GeoJSON or GeoParquet store key or FileRef (`--parse geojson|geoparquet`, else from its extension); it is served from an optimized GeoParquet copy unless `--skip-optimize`, and `--skip-optimize --build-artifact` serves a GeoJSON as chunks. `--function` instead names a function pipeline whose GeoJSON FeatureCollection is the layer, its features cached for `--ttl` (default 60s). Each `--field` is a property the public may see (none: geometry only); `--max-items` caps the features one query answers (default 1000); `--min-zoom` / `--max-zoom` bound visibility; `--style` or the colour flags style tiles; `--filter` is the default filter. Adds `layer: { name, route, store, source, source_kind, …, serving }` and keeps the rest of the payload.

## Flags

- `--name` (required): The layer's name: 1–64 letters, digits, - or _. Publishing a name again updates it.
- `--route` (required): Where the layer answers, under /ms/{owner}/{project}/.
- `--from`: The source: a GeoJSON or GeoParquet store key, or a FileRef through {{ }}. Required unless --function.
- `--parse`: How --from is read: geojson or geoparquet (default: from its extension).
- `--bbox-optional`: Serve queries without a bbox. Default: a bbox is required.
- `--max-items`: The most features one query answers (default 1000, at most 50000).
- `--field`: A source property the public may see (repeat, or one {{ [list] }}). None: geometry only.
- `--min-zoom`: The lowest zoom the layer shows at (0–24).
- `--max-zoom`: The highest zoom the layer shows at (0–24).
- `--skip-optimize`: Serve the source as it is, without the optimized GeoParquet copy.
- `--build-artifact`: With --skip-optimize and a GeoJSON source: build a chunked artifact in the cache tier and serve that instead of the file.
- `--fill`: Polygon fill colour (default: rgba(65,105,225,128)).
- `--stroke`: Stroke colour (default: #1E3CA0DC).
- `--stroke-width`: Stroke width in pixels, 0–100 (default: 1).
- `--point-radius`: Point radius in pixels, 0–100 (default: 4).
- `--point-color`: Point fill colour (default: #DC3232C8).
- `--style`: A style expression, e.g. cb(population,5,YlOrRd); overrides the colour flags.
- `--filter`: The default filter, e.g. category:residential;value>100.
- `--function`: A function pipeline whose GeoJSON FeatureCollection is the layer; instead of --from.
- `--ttl`: How long a function layer's features are cached, e.g. 60s or 5m (default 60s).
- `--store`: The project store to write to: `local`, or the id of an `s3` credential. Saved explicitly when the pipeline is registered (default: the project's default store at that moment)

## Examples

### Publish a GeoParquet layer

```
| mapserver.layer.publish --name suburbs --route suburbs --from datasets/suburbs.parquet --field name --field postcode --min-zoom 8 --max-zoom 14
```

A page loads it with `zeb/deckgl` from `/ms/{owner}/{project}/suburbs` (help topic `guide/mapserver`).

It answers:

```json
{
  "layer": {
    "name": "suburbs",
    "route": "suburbs",
    "store": "local",
    "source": "mapserver/.optimized/suburbs.spatial.parquet",
    "source_kind": "geoparquet",
    "min_zoom": 8,
    "max_zoom": 14,
    "bbox_required": true,
    "max_items": 1000,
    "fields": [
      "name",
      "postcode"
    ],
    "feature_count": 312,
    "chunk_count": null,
    "style": null,
    "filter": null,
    "function": null,
    "ttl": null,
    "serving": true,
    "optimization": {
      "applied": true,
      "source_format": "parquet",
      "rows": 312
    }
  }
}
```

### A layer a function pipeline draws

```
| mapserver.layer.publish --name live --route live --function sensors/positions --ttl 30s --bbox-optional
```
