# Vegetation: planting a site

Plant a whole site in **one call**. Do not compute your own tree positions: an area covers the
terrain the way the Vegetation panel's Add → Area does when someone clicks a terrain.

```json
jifto_trees {"type": "deciduous", "area": {"terrain": "Site", "spacing_m": 8}}
```

The reply carries the ecosystem's id and its tree count:

```json
{"ecosystem": "<id>", "kind": "area", "planted": 214, "on": "Site", "spacing_m": 8,
 "jitter_pct": 100, "scale_pct": [80, 120], "ids": ["<id>"], "type": "deciduous", "height_m": 12, "crown_m": 7.2}
```

An **ecosystem** is one object holding every tree:

- It stands on the terrain as it is modelled now (the published surface, not the Base).
- Trees keep off the terrain's paths, pads, ponds, streams, walls and stairs, and off their cut and
  fill slopes. A modifier's `Exclude Vegetation` setting switches this off
  (`jifto_terrain set ... "settings": {"Exclude Vegetation": false}`); material areas let trees grow
  unless it is on.
- It **follows the terrain's edits** in the same call: add a path or move a pad, and the trees
  leave the new ground and stand on the new surface. Plant once, before or after the design loop.
- It appears in the Vegetation panel's Ecosystems list, where people can change its spacing, type and
  size later. Analyses see it (shade, porosity, wind drag) and captures draw it.
- Delete it with `jifto_geometry {"action": "delete", "ids": ["<ecosystem id>"]}`; plant again to
  change spacing or type.
- `jifto_status` lists every ecosystem under `vegetation` with the trees it holds **now**. After
  terrain edits, read the count for a report there, not from the planting reply. Limit curves may sit
  on a hidden layer; they still limit.

## Choosing where

| Want | Call |
|---|---|
| The whole terrain | `"area": {"terrain": "Site"}` |
| A wood inside a closed curve on it | `"area": {"curve": "<closed curve id>"}, "on_terrain": "Site"` |
| Several woods, one ecosystem | `"area": {"terrain": "Site", "within": ["<curve id>", "<curve id>"]}` |
| The site but clear of buildings or a lawn | `"area": {"terrain": "Site", "avoid": ["<building id>", "<lawn curve id>"]}` |
| A surface or mesh that is not a terrain (a roof garden, a courtyard slab) | `"area": {"object": "<surface or mesh id>"}` |
| A row or avenue along a curve | `"along": {"curve": "<curve id>", "spacing_m": 10}, "on_terrain": "Site"` |
| A few specimen trees | `"points": [[x, y, z], ...], "on_terrain": "Site"` |

- `within` takes closed curves: trees grow only inside them. `avoid` takes curves or objects: trees
  keep out of closed curves and footprints, and `buffer_m` (default 3 m) clear of open curves and
  objects. Both are the panel's Limits, and the ecosystem follows edits of these curves too.
- `along` makes a line ecosystem: trees on the curve, `spacing_m` apart. Its trees stand on the curve
  itself, so with `on_terrain` jifto lays a copy of the curve on the terrain's surface (layer
  `Tree lines`, returned as `curve`), and the trees follow that copy. The curve you gave keeps its heights,
  so a path's curve can carry an avenue without changing the path.
- `points` are single trees, one object each, up to 5000 per call. Use them for a handful of
  specimens, never to fill an area.

## Density and variety

- `spacing_m`: distance between trees. The default is the crown diameter (crowns touch: a wood). Twice
  the crown reads as parkland; 1.5 times as an orchard. At least 1 m.
- `jitter` (areas, 0 to 100 %, default 100): how far trees move off the grid. 0 is a planted grid.
- `scale_min`, `scale_max` (40 to 200 %, default 80 and 120): the smallest and largest tree, as a
  share of `height_m` and `crown_m`.
- Mix species by planting several ecosystems on the same ground, each with its own type and spacing
  (for example conifers within the north curve, deciduous trees elsewhere with `avoid` on that
  curve).

## Types

`deciduous`, `conifer`, `columnar`, `umbrella`, `palm`, `bush` (the panel's Type list). `height_m` and
`crown_m` override the type's size. Deciduous trees are bare in winter when the analysis date is in
winter.

## Pitfalls

- Planting trees one by one over a site makes thousands of objects that do not follow the terrain.
  Use one area.
- An area on the terrain before a path is added already gives way to the path; there is no need to
  replant after terrain edits.
- An area needs ground: a terrain, a surface or mesh, or a closed curve with `on_terrain`. A closed
  curve alone has nothing to stand on.
- Very large sites at small spacing: one ecosystem holds up to 100,000 trees per call; use a larger
  spacing beyond that.
