Large areas, multi-flight lidar analysis, and landscape zones
All lidar analysis routines in @tilemapper/surface are pure and deterministic.
1. Township area limits and cell sizing (items 301–302, plan v3 item 378)
Projects may cover any piece of ground up to one Public Land Survey System township (23,040 acres / 36 square miles / 93.24 km²). Areas larger than 23,040 acres are refused both in the UI and server-side in job-actions.ts before enqueuing elevation discovery or terrain builds.
One-click Get the ground (and Get terrain) passes requested_cell_m from recommendedCellSizeM (packages/surface/src/lidar.ts) on the terrain.discover job. From finding NB1 (round 7 of plan v4) the worker forwards it to terrain.build as min_cell_m, a floor, not as a request: see "Which builds send which size" below. The worker honors the chosen cell size for both ready-made DEMs (resampling coarser grids onto whole multiples of the cell size with GDAL area-weighted averaging, Resampling.average, and refusing requests finer than the source's own grid) and point clouds (0.25, 0.5, 1, 2, 3, and 5 m via PDAL inverse distance weighting). The Elevation data panel also lets a person pick coarser grids on a ready-made DEM or any of the six point-cloud sizes, and Terrain source always reports the built cell size, the source's own cell size, and the resampling method.
Which builds send which size (finding NB1)
A size a person picks is a request: the worker builds exactly that or refuses, saying what the data supports. A size the app suggests by itself was, until NB1, sent the same way, so a point cloud whose ground-only density (measured by the build, sample_density(..., ground_only=True)) supported only a coarser grid than the search's all-returns density or quality level said failed for good, where a build with no size would have stepped up. Now the app's own suggestion is a floor: nothing finer is built, and from there the worker steps up exactly as a build with no size does, first to what the ground density supports (finest_cell_m, one ground point a cell, GROUND_POINTS_PER_CELL, or the quality level's SUPPORTED_BY_QUALITY_M when density can't be measured), then to the finest of CELL_CHOICES_M the worker can hold (memory.most_cells). No new threshold: these are the worker's own, with their sources in pointcloud.py, ranking.py and memory.py. When it lands coarser than suggested, the result's cell_note says what size and why ("Built at 2 m, not the 1 m suggested for an area this size: this point cloud has about 0.9 ground points per square meter, which supports 2 m at the finest."), and the built terrain's card shows it beside the grid.
| What starts it | Where | Size sent | What the worker does when the data can't support it |
|---|---|---|---|
| Get the ground, one click (also Get terrain and the outlet survey's search-and-build) | findElevationData(projectId, true) → terrain.discover |
requested_cell_m = recommendedCellSizeM(acres) on the search |
Worker from NB1: queues terrain.build with min_cell_m = that size, which steps up and says why. An older worker forwards it as a hard requested_cell_m (DEM: its own grid where coarser; point cloud: the larger of it and the search's stated detail) and fails a point cloud too sparse for it. |
| The automatic build when an area is saved | startGroundForArea → terrain.discover |
As one click | As one click. |
| Guided Build the ground, for a flight the search found but didn't build (a slow source, or a search on its own) | buildSearchedFlight → terrain.build |
appStartedBuildCellM: a DEM gets the area's size where that is coarser than its own grid; a point cloud gets none |
A DEM is coarsened, which can't fail for its data. A point cloud is built at the finest grid its ground density supports and the worker can hold. Before NB1, a point cloud past 1,000 acres was sent a hard area size, and a large DEM none, so it failed as too large. |
| Rebuild when the flight changes mid-build | rebuildOnFlight → buildSearchedFlight |
As guided Build | As guided Build. Before NB1 it sent no size, so a large 1 m DEM failed as too large. |
| Build in the Elevation data panel, with a size picked | buildTerrain(projectId, id, size) |
requested_cell_m as picked; none for "Finest supported" or "Source grid" |
A hard request: refused with the size the data supports ("This point cloud has about 0.9 ground points per square meter, which supports a 2 m grid, but not 1 m."), finer than a DEM's grid ("This source's grid is 1 m, so it can't be built at 0.5 m ..."), or too large ("A 2 m grid would fit."). Unchanged. |
| Your own data | buildTerrain(projectId, "upload:…") |
None | The file's own grid, or the finest a point cloud supports. Unchanged. |
| Try again on a failed build | retryJob → retry_job |
The failed job's own payload | Runs the same payload again. A one-click build queued by an older worker with a hard size keeps it on retry; pressing Get the ground again starts a new search that carries the floor. |
| A rebuild after the worker's pipeline changes | No path of its own | Whichever path above starts it | PIPELINE_VERSION is in the cache key, so the next build by any path builds anew with that path's size. |
| A comparison flight or first-return surface | terrain.build_flight |
None: it grids onto the current terrain's own grid | Not a cell-size choice; unchanged. |
Old and new workers: every worker refuses a payload field it doesn't know (extra="forbid"), and the worker is deployed by hand after the app. So the app sends nothing new: min_cell_m is written only by a worker from NB1 on, into the build it queues after a search, and appStartedBuildCellM sends only what can't fail for its own suggestion on either worker. Against an older worker, one click and the automatic build behave as before NB1 until the worker is deployed; guided Build and the rebuild on a flight are mended on both. A result from an older worker has no cell_note, which reads as null.
Area steps (starting points, not measured until item 379's benchmark runs)
The area steps below are starting points, not measurements: judgment carried from plan v2 and named in packages/surface/src/lidar.ts as ONE_METER_MAX_ACRES, TWO_METER_MAX_ACRES and THREE_METER_MAX_ACRES, which recommendedCellSizeM reads. They were chosen to keep a square project near 3.7 to 4.5 million cells, well inside the worker's ~36.3 million-cell assumed budget. No build at these sizes has been timed or measured on the production workers. Item 379, that benchmark, was deferred by the owner on 2026-11-29; until it runs, these steps stay as they are and a township-scale build on production is not promised. The Lidar analysis panel says so beside the project's area: "Get the ground builds an area this size at 2 m cells, or at the source's own cell size where that is coarser. The acre steps that choose it are a starting point, not yet measured on the build workers."
| Project area | Requested cell size | Approximate project grid (arithmetic) | Basis |
|---|---|---|---|
| Up to 1,000 acres | 1.0 m | ≤ 4.0 million cells | Starting point, not measured (ONE_METER_MAX_ACRES = 1000) |
| 1,001 to 4,000 acres | 2.0 m | ≤ 4.0 million cells | Starting point, not measured (TWO_METER_MAX_ACRES = 4000) |
| 4,001 to 10,000 acres | 3.0 m | ≤ 4.5 million cells | Starting point, not measured (THREE_METER_MAX_ACRES = 10000) |
| 10,001 to 23,040 acres | 5.0 m | ≤ 3.7 million cells | Starting point, not measured (above THREE_METER_MAX_ACRES, to the township limit MAX_PROJECT_ACRES = 23040) |
Township memory arithmetic (not a measured build)
A square 1-township area (23,040 acres = 6 mi × 6 mi = 9,656.064 m on a side) becomes 9,856.064 m on a side (97.14 million m²) with the worker's 100 m AOI buffer (DEFAULT_BUFFER_M = 100 in gis_worker/terrain/aoi.py). Under the memory budget's own arithmetic (gis_worker/terrain/memory.py: assumed 4 GiB container × 0.75 job share − 300 MiB library base = 2,906,652,672 bytes at 80 bytes/cell = 36,333,158 cells max):
| Cell size | Grid (cells) | Total cells | Grid memory at 80 B/cell | With 300 MiB base | Fits 4 GiB budget? |
|---|---|---|---|---|---|
| 0.25 m | 39,425 × 39,425 | 1,554,330,625 | 115.81 GiB | 116.10 GiB | No (refused) |
| 0.5 m | 19,713 × 19,713 | 388,602,369 | 28.95 GiB | 29.25 GiB | No (refused) |
| 1.0 m | 9,857 × 9,857 | 97,160,449 | 7.24 GiB | 7.53 GiB | No (refused) |
| 2.0 m | 4,929 × 4,929 | 24,295,041 | 1.81 GiB | 2.10 GiB | Yes (arithmetic) |
| 3.0 m | 3,286 × 3,286 | 10,797,796 | 0.80 GiB | 1.10 GiB | Yes (arithmetic) |
| 5.0 m | 1,972 × 1,972 | 3,888,784 | 0.29 GiB | 0.58 GiB | Yes (arithmetic) |
These figures are arithmetic from memory.py, not a measured build. Item 367 also keeps outside_entry_m2 (~4 bytes/cell) to the end of hydrology without re-measuring the 80 bytes/cell budget, whole-tile LAZ sources remain capped at 16 tiles, and the budget does not model wall-clock runtime against the 20-minute build deadline.
For sharp zooming without a tile server, browser lidar analysis overlays are partitioned into a grid of 512 × 512 CSP-safe canvas sources (buildOverlayTileGrid) with exact UTM-to-WGS84 corner coordinates, and hillshade and elevation color draw tile by tile from windowed COG overview reads (see relief.md).
2. Elevation change between lidar flights (items 303–305, plan v3 items 381–382)
Building a second flight on the current terrain's grid (item 381)
An older dataset from the project's discovery list can be built alongside the terrain in use via the terrain.build_flight job (build_comparison_flight in services/gis-worker/gis_worker/terrain/build.py). Older flights in public 3DEP catalogs are commonly available only as point clouds (usgs_ept or usgs_laz), with no older 1 m DEM, so the worker builds comparison flights from point clouds as well as DEMs, with retries for transient streaming EPT refusals and resumable tile downloads.
- Exact grid match: Before reading the older flight, the worker downloads the current primary terrain's stored
dem_originalCOG and extracts itsTargetGrid(crs_epsg, affinetransformorigin and pixel spacing,width, andheight) along with its valid-cell mask. Ready-made DEMs are read directly onto that transform (copying cells when exact,Resampling.averagewhen coarsening,Resampling.bilinearwhen reprojecting/shifting, and refusing requests finer than the source DEM's native grid), and point clouds are streamed through PDALwriters.gdalwith the exactorigin_x,origin_y,width,height, andresolution. The finished surface is verified cell for cell againstTargetGrid(grids_match) and clipped to the current terrain's valid cells. - Refusals: The build is refused before saving if the current terrain lacks a recorded vertical datum or is not NAVD88 meters, if the older flight states no vertical datum or a vertical datum that cannot be reconciled to NAVD88 meters (such as NGVD29), if the older flight has no elevation data or ground points overlapping the current terrain, if the target grid exceeds the worker's memory budget, if an older DEM is coarser than the current terrain's grid, or if the built heights fail the check against USGS's 1/3 arc-second DEM.
- Isolation from the terrain in use: Comparison flights are saved in
public.terrain_modelswithrole = 'comparison'andaligned_to_terrain_idpointing to the primary terrain, storing onlydem_original(no hydrology, overlays, or contours). Because the terrain in use is always resolved from the latest succeededterrain.buildjob, building a comparison flight never changes the terrain in use, tile results, cover checks, revision fingerprints, water tools, or surface earthwork. Both the terrain in use (In use) and any comparison flights (Comparison only) are listed under Elevation data with their collection dates, source, stated accuracy (explicitly stating when accuracy is not recorded), vertical datum, cell size, and how each was made.
Comparing flights without handling a file (item 382)
Given a newer bare-earth DEM z_new and an older bare-earth DEM z_old on a common grid:
Δz = z_new - z_old- Project flights first: In Lidar analysis, Compare flights and Measure change volume pick the earlier flight directly from the project's comparison terrains aligned to the current terrain, reading vertical datum and stated vertical accuracy (
RMSE_zfrom USGS Lidar Base Specification 2025 rev. A, Table 4 (absolute vertical accuracy) viaquality_levelwhenmeets_specificationis notfalse) straight from each terrain's database record. Loading a GeoTIFF from disk stays available under More options, using the same engine and uncertainty rules and keeping item 431's missing-value tag and plausible-height guards untouched. - Datum & accuracy gate: If either flight lacks a stated vertical datum (
source_vertical_epsgis missing), if the two flights have different vertical datums without conversion, if either flight's record omits vertical accuracy (or states it is below specification), or if the grids do not match in dimensions, origin, and cell size, the comparison is refused and no change map or volume uncertainty range is shown. - Datum read from the record: Each project flight's vertical EPSG is read from its
terrain_models.vertical_epsgcolumn (the worker stores every build as NAVD88 meters, EPSG:5703), withprovenance.source_vertical_epsgsaying what the source came in. A terrain with no recorded source datum predates that record and is treated as unknown. The engine (computeElevationChangeinpackages/surface/src/lidar.ts) refuses two different vertical EPSGs. - Geoid models: NAVD88 heights from different flights may have been made with different geoid models, such as GEOID03 for a 2008 flight and GEOID18 for a recent one, and that puts an offset between the two surfaces. Each flight's model is read from
provenance.geoid. When the two differ, or either is not recorded (a hand-loaded GeoTIFF never records one), the engine still differences them but returns a caution naming both models and saying the offset between them is not removed. The panel shows it under the change, and the printed map carries it under the change's legend entry. No offset is estimated or removed: there is no cited figure here to remove it with. - Uncertainty blank band: Combining each flight's stated vertical accuracy (
RMSE_z,newandRMSE_z,old) in quadrature gives the 95% confidence threshold (ASPRS Positional Accuracy Standards):τ_95 = 1.96 × √(RMSE_z,new² + RMSE_z,old²)- Cells with
|Δz| ≤ τ_95are left blank (transparent) on the change map, and the panel states both individual accuracies, the combined vertical accuracy, andτ_95identically whether the earlier surface came from the project's terrains or from a hand-loaded file.
- Change volume: Over a drawn polygon of area
A, gained volume integratesΔz > 0, lost volume integratesΔz < 0, and the stated uncertainty range is± A × √(RMSE_z,new² + RMSE_z,old²). - Where one flight has no heights (review finding NB2, 2026-12-02):
Ais the compared area only: the cells whose centres lie in the drawn polygon and have heights in both flights. Every cell centre in the polygon is counted, past the terrain's edge too, and the cells missing in one flight or the other are said beside the figures: "0.02 ac of the 0.10 ac drawn has no heights in one flight or the other, and is left out." When less than half the drawn cells were compared (CHANGE_VOLUME_MIN_COMPARED_SHARE = 0.5, judgment, a starting point the owner hasn't set), no area, volume or range is given, and the panel says what share was compared and to draw where both flights have heights. An area with nothing compared gets that refusal, never a zero. The cell-size refusal counts the drawn cells, not the compared ones, so a void doesn't read as coarse terrain.- Worked case (by hand, matched exactly by
packages/surface/src/change-volume-missing.test.ts): a 20 by 20 grid of 1 m cells, the newer flight 1 m above the older everywhere the older has heights. With heights in the older flight's top 15 rows, 300 of 400 cells are compared:300 × 1 m² × 1 m = 300 m³gained over 300 m², and100 m² = 0.0247 acleft out. With only its top 5 rows, 100 of 400 cells (25%) are compared, under half, and the volume is withheld: "Only 25% of this area has heights in both flights, so no volume is given."
- Worked case (by hand, matched exactly by
A file loaded by hand (plan v3 item 431)
A second flight or a first-return surface loaded from a person's disk is read with two guards before anything is compared.
The missing-value tag is matched as the file stores it. GDAL writes the tag as text, such as
-9999.1. A 32-bit band can't hold that exactly and stores-9999.099609375. Matching only the written tag takes every missing cell for ground about 10 km down, which shows as a solid gain with a volume to match. In a 32-bit band both forms count as missing, and each missing cell is read as no value at all. A 64-bit band stores the tag exactly, and can hold its 32-bit rounding as a real height (300.100006103515625m beside a tag of300.1), so it is matched on the tag alone (review finding A2, 2026-12-02).Heights outside the worker's own limits are refused. The terrain worker accepts ground between
-100 mand4,500 m(LOWEST_PLAUSIBLE_MandHIGHEST_PLAUSIBLE_Minservices/gis-worker/gis_worker/terrain/dem.py: lower than Death Valley or higher than Mount Whitney can't be real here). A file with a height outside that range has the wrong units, the wrong datum, or missing cells it doesn't tag, and is not used.What the file says about itself wins. The vertical datum a file declares (
VerticalCSTypeGeoKey) is kept through the conversion to meters: NAVD88 in feet (6360, 8228) is NAVD88 (5703), and NGVD29 (5702, 7968) stays NGVD29. A datum chosen in the panel that disagrees with the file's is refused, naming both, as a file in another horizontal system is. Height units work the same way: a unit chosen that disagrees with what the file states is refused. A file that states neither takes the person's choice, and the panel says the file itself does not say.The unit choice belongs to one file. The earlier flight and the first-return surface each have their own, and a newly loaded file starts from what it states, never from the last file's choice. Before this, feet left chosen for one file turned a 300 m file stated in meters into 91.44 m, inside the plausible range, and showed a false gain of 208.56 m.
Reference case. A 10 by 10 grid of 32-bit heights with its top four rows tagged -9999.1, compared with the same ground untagged: 0 changed cells, 0 m³ gained and 0 m³ lost, and the 40 tagged cells are missing from the comparison. Before this, those 40 cells read as about 10,249 m of change each.
3. First-return surface and heights above ground (items 306–308, plan v3 items 383–384)
Building a first-return surface from the project's point cloud (item 383)
Where the project's discovery list includes a point cloud (usgs_ept or usgs_laz) with a vertical datum reconcilable to NAVD88 meters, the worker builds a first-return Digital Surface Model (DSM) onto the exact grid (TargetGrid) of the terrain in use via terrain.build_flight with surface = "first_return" (read_point_cloud_first_return in services/gis-worker/gis_worker/terrain/pointcloud.py).
- Point filtering and excluded classes: Every point flagged
Withheld != 0is dropped (matching the ground build'sWithheld[0:0]rule; at Fargo, 45% of public EPT points are flagged withheld). ASPRS LAS 1.4 noise classes 7 (Low Point / noise) and 18 (High Noise) are excluded in separate PDAL range stages (Classification![7:7],Classification![18:18]), matching the ground build's exclusion of non-ground noise classes. Before filtering to first returns, the worker checksReturnNumberstatistics across the remaining points; if every point hasReturnNumber = 0(the point cloud states no return numbers), the build is refused with a plain explanation. Only first returns (ReturnNumber = 1) are kept for gridding. - Gridding rule (
first_return_max— highest first return in each cell): Points are binned strictly into their containing grid cell (writers.gdalwithbinmode = true,output_type = "max") onto the terrain in use's exactorigin_x,origin_y,width,height, andresolution_m, then clipped to the terrain in use's valid-cell mask. Small empty cells up to 3 cells across (GAP_FILL_CELLS = 3, matching the ground build) are filled by PDAL's fallback window while wider voids (such as open water with no returns) stay empty (NODATA). Taking the highest first return inside each cell rather than inverse distance weighting or a cell mean preserves canopy tops and roof ridges without smearing them downward or dilating tall objects horizontally into neighboring open-ground cells. - Method limits:
- Sloping bare ground: On a sloped bare-earth cell of grade
sand cell sizeΔx, the highest point inside the cell sits up to0.5 × (|∂z/∂x| + |∂z/∂y|) × Δx(at mosts × Δx / √2) above the cell center (for example, up to 1.5 cm on a 2.24% slope at 1 m cells). - 3-cell gap filling near edges: Where no first return lands inside an empty cell beside a tree or roof, the 3-cell fallback window interpolates from filled neighbors and can slightly soften the edge of a sparse gap.
- Temporary surface cover and reflections: Standing crops, snowdrifts, parked machinery, and specular water reflections reflect first returns and appear as height above ground.
- Canopy penetration: Laser pulses can pass through sparse branches before triggering a first return, so lidar tree heights can understate true crown tops beyond the stated bare-earth vertical accuracy.
- Different flights: If the terrain in use was built from a different dataset than the point cloud (for example, a ready-made 1 m DEM or a different collection year), subtracting the two includes any real ground change or vertical offset between flights as well as what stands on the ground.
- Sloping bare ground: On a sloped bare-earth cell of grade
- Storage and isolation: First-return surfaces are stored in
public.terrain_modelswithrole = 'first_return',aligned_to_terrain_idpointing to the primary terrain, andartifacts.dsmpointing to adsm/*.tifCOG (neverdem_original). They are listed under Elevation data asFirst returns onlyand never become the terrain in use or enter tile sizing, cover checks, water tools, or earthwork.
Reading heights from the project's own surface (item 384)
Subtracting the terrain in use's bare-earth DEM z_DEM from the aligned first-return surface z_DSM yields Height Above Ground:
HAG = max(0, z_DSM - z_DEM)
In Lidar analysis, Show heights, clicking a point on the map for its height, and Draw dual profile (sampling both z_DEM and z_DSM along a drawn line) read the project's stored first-return surface directly with no file to load. Loading a first-return GeoTIFF from disk stays under More options, preserving item 431's missing-value tag and plausible-height guards. Its vertical datum follows the earlier flight's rule (firstReturnDatumProblem in apps/web/src/lib/terrain/local-geotiff.ts, review finding NB6, 2026-12-02): a file that states none is set against the ground only once the person chooses one under Surface model vertical datum, and a datum, stated or chosen, that disagrees with the active terrain's is refused. Without that, any offset between two datums would read as height above the ground.
- Same-flight vs. different-flight notice: Whenever a height is shown (summary, clicked point readout, and dual-surface profile), the panel states whether the ground and first returns came from the same point cloud dataset. If they came from different datasets, both dataset names and collection dates are shown with a warning that the difference includes any ground change or vertical offset between flights.
- Accuracy stated, not assumed: Height uncertainty comes from the record's stated vertical accuracy (
RMSE_zfrom USGS Lidar Base Specification 2025 rev. A, Table 4 (absolute vertical accuracy), quoted at 95% confidence as1.96 × RMSE_zfor one point cloud or1.96 × √(RMSE_z,ground² + RMSE_z,surface²)across two different datasets). Where either record omits vertical accuracy or falls below specification (or for a hand-loaded file), the panel states that vertical accuracy is not recorded and gives no uncertainty range. - When no first-return surface can be built: Where the discovery list holds no point cloud for the ground, where no search has been run, where the listed point cloud lacks a matching vertical datum, or where a point cloud states no return numbers, the panel states why in plain words and tells the person what they can do instead.
4. Landscape position and wetness zones (items 309–310, plan v3 item 385)
The formulas for the two indices come from published work cited in the codebase: standardized Topographic Position Index after Weiss (2001) and Topographic Wetness Index ln(a / tan β) after Beven & Kirkby (1979). Every threshold, window size, slope floor, smoothing rule, and display range that turns those indices into landscape zones or wetness shading is a judgment chosen for agricultural fields, not a finding from a cited source.
- Topographic Position Index (TPI, after Weiss 2001):
- Square neighborhood window: For an entered neighborhood half-width
R(default50 m, adjustable from10 mto250 m, all judgments), a 2D summed-area table averages every valid cell inside a square of2 · r + 1cells on a side ([row - r, row + r] × [col - r, col + r], clipped at grid borders), wherer = max(1, round(R / Δx)). The square's side length is(2 · r + 1) · Δx(for example,101 m/331 fton a1 mDEM at the50 mdefault, or105 m/344 fton a5 mDEM). The Lidar analysis panel states this square and its side in feet and meters. TPI(x, y) = z(x, y) - mean_square(x, y)- Mean-centered and standardized against
max(σ, 0.05 m)(0.05 mfloor is a judgment):z_TPI = (TPI - mean(TPI)) / max(σ, 0.05):Hilltop:z_TPI > +0.5(judgment)Depression:z_TPI < -0.5(judgment)Sideslope:|z_TPI| ≤ 0.5and local slope≥ 1%(0.01, judgment; centered interior differences, one-sided along borders and NoData edges)Toeslope:|z_TPI| ≤ 0.5and local slope< 1%(judgment)
- Square neighborhood window: For an entered neighborhood half-width
- Topographic Wetness Index (TWI, after Beven & Kirkby 1979):
TWI = ln(a / tan(β)), wherea = N_acc × Δxis upslope area per unit contour width (N_acc ≥ 1cell, including the cell itself) andtan(β)is floored at0.001(0.1%grade, judgment) on level ground.- Wetness is drawn as a continuous pale-to-dark blue ramp stretched from
4(driest) to16(wettest); those display bounds are a judgment (WETNESS_RANGEinapps/web/src/lib/ui/map-key.ts). From0.6of that stretch, TWI11.2and up, subtle horizontal lines are drawn over the color as a second cue that survives grayscale print. That cutoff is a judgment too (WETNESS_LINE_THRESHOLDinapps/web/src/lib/ui/overlay-patterns.ts), not a wet/dry boundary from a source.
- Zone smoothing & GIS exports (judgments): A
3×3majority filter (1pass by default) followed by 4-connected minimum-patch absorption (0.25 acdefault in the panel, iterated up to8passes) removes single-cell speckle and tiny slivers before summarizing acres and exporting hole-preserving GeoJSON and binary ESRI Shapefile (.shp/.shx/.dbf/.prj) zones.
Zone thresholds (all judgments)
| Threshold | Constant | Value | Basis |
|---|---|---|---|
Default TPI square neighborhood half-width (R) |
TPI_DEFAULT_RADIUS_M |
50 m (square side (2·round(R/Δx)+1)·Δx, e.g. 101 m / 331 ft on 1 m cells) |
Starting point (not from a cited table) |
| Adjustable TPI neighborhood half-width range | TPI_RADIUS_MIN_M, TPI_RADIUS_MAX_M |
10 m to 250 m |
Starting point (panel bounds) |
| TPI standard-deviation floor | TPI_MIN_STD_DEV_M |
0.05 m |
Starting point (prevents flat-ground noise from inflating z_TPI) |
| Hilltop cutoff | TPI_Z_THRESHOLD |
z_TPI > +0.5 |
Starting point (4-class split adapted from Weiss 2001 standardized TPI) |
| Depression cutoff | TPI_Z_THRESHOLD |
z_TPI < -0.5 |
Starting point (4-class split adapted from Weiss 2001 standardized TPI) |
| Sideslope vs. toeslope local slope cutoff | TPI_SIDESLOPE_MIN_GRADE |
1% (0.01 m/m) for -0.5 ≤ z_TPI ≤ +0.5 |
Starting point (separates sloping from level ground) |
| Zone majority-filter smoothing | ZONE_SMOOTH_KERNEL_SIDE_CELLS, ZONE_DEFAULT_SMOOTH_PASSES |
3×3 cell kernel, 1 pass by default |
Starting point (removes single-cell speckle) |
| Minimum connected zone size & absorption cap | ZONE_DEFAULT_MIN_ACRES, ZONE_ABSORB_MAX_PASSES |
0.25 ac default (4-connected), up to 8 passes |
Starting point (absorbs tiny slivers into neighboring zones) |
TWI level-ground slope floor (tan β) |
TWI_MIN_SLOPE |
0.001 (0.1% grade) |
Starting point (avoids division by zero in Beven & Kirkby 1979 ln(a / tan β)) |
| TWI map color stretch | WETNESS_RANGE |
4 (driest) to 16 (wettest), a continuous color ramp |
Starting point (visual display range) |
| Slope band starting edges (field zones) | STARTING_BAND_QUANTILES |
slopes below which 0.2, 0.4, 0.6, 0.8 of the field's cells lie, rounded to a readable percent |
Starting point (the slope layer's own starting bands, changed by typing) |
| Height band starting edges (field zones) | STARTING_ELEVATION_QUANTILES |
heights below which 0.2, 0.4, 0.6, 0.8 of the field's cells lie |
Starting point (changed by typing) |
| Height band edge rounding (field zones) | elevationEdgeStepFt |
0.1 ft under 5 ft of relief, 0.5 ft under 20 ft, 1 ft under 100 ft, 5 ft above |
Starting point (for edges that read easily) |
| TWI wet-end line pattern | WETNESS_LINE_THRESHOLD |
0.6 of the color stretch, that is TWI ≥ 11.2: horizontal lines drawn over the color |
Starting point (a second cue on the wettest ground that survives grayscale print; not a wet/dry boundary from a source) |
5. A field's zones, and acres that add up (plan v4 items 486 to 489)
What zones are made from (item 486)
A field's zones are made from one thing at a time, each named in plain words with its exact term a tap away (apps/web/src/lib/ui/plain-terms.ts):
| Plain name | Exact term | How a cell gets its zone |
|---|---|---|
| Lay of the land | Landscape position (topographic position index) | Section 4: High ground (Hilltop), Side slope (Sideslope), Foot of slope (Toeslope), Low hollow (Depression) |
| Slope | Slope bands (Horn 1981) | The band its slope falls in, by computeSlope at one cell apart and bandIndexOf, the same method, edges and starting bands (startingSlopeBands over the field's largest outer ring) the slope layer uses, so the two never disagree (slope-and-grade.md) |
| Height | Elevation bands (NAVD88) | The band its height falls in (elevationBandZoneClasses) |
| Soil map | Soil map units (NRCS SSURGO) | The map unit under its center (rasterizeZonePolygons); soil lines are drawn at a far broader scale than 1 m ground, so a soil zone's edge is only as close as the soil map's own line |
Slope and height bands start from the spread of the field's own ground: the edges at which a fifth, two fifths, three fifths and four fifths of the field's cells lie below (nearest rank), as the slope bands of item 447 start. They are starting points, named so on the screen, and a person can type their own. Height edges are rounded to a readable step in feet by the ground's relief (table above). Repeated edges are dropped, so flat ground has fewer bands, never an empty one.
All four are made on the whole terrain, smoothed by the same 3×3 majority filter and smallest zone as section 4 (smoothZoneGrid, which now takes up to 255 kinds of zone), and only then cut to the field, so a neighborhood or a slope near the field's edge reads the ground beyond it.
Cut to the field, holes kept (item 487)
Why the old table didn't add up. Plan v3's audit saw a zones table report more acres than its project held. The zones were counted over every cell of the terrain, and the terrain is the fields plus a 100 m buffer (DEFAULT_BUFFER_M in services/gis-worker/gis_worker/terrain/aoi.py) and any corridors between fields. The zones were never cut to a field. Zones are made in the browser, in the terrain worker (apps/web/src/lib/terrain/terrain-calc.ts), not by the GIS worker.
The cut (cutZonesToField in packages/surface/src/zones.ts) is exact, not cell-center counting. A zone's outline is made of two kinds of edge, each a piece of a straight line: the field's own edge where the zone lies on its inside, split at every grid line it crosses, and the grid's cell edges between two zones that lie inside the field, split where the field's edge crosses them. Field edges run with the field on their left (outer rings counterclockwise, holes clockwise), and each cell edge is written once for the zone on each side, so the pieces of each zone chain into closed rings. Where two rings of a zone touch at a point, the sharpest left turn separates outer cells touching at a corner, and any repeated vertex left in a closed edge cycle (such as a hole touching an outer ring or two holes touching at a corner) is then split into vertex-simple rings before outer rings and holes are grouped. A field edge that runs along a grid line is kept once, by the field. Ground in the field with no zone (no ground, no slope, no soil unit, or past the terrain's edge) is a zone of its own, code 0, so the zones and the no-data ground cover the field exactly once.
Check. 200 seeded random fields over a random class grid (zones.test.ts): each zone's area matches the sum, over its cells, of the area of the cell clipped to the field by Sutherland–Hodgman, worked separately in the test, to 1e-6 of the field's area, and the zones sum to the field's own area. Worked by hand there: a 3 m square over two zones splits 4.5 m² and 4.5 m²; a 10 m square with a 4 m hole across two zones gives 42 m² each.
The one rule for acres
Every zone acre is ground area on the WGS 84 ellipsoid, worked from the outline in longitude and latitude by ellipsoidAreaM2 (packages/surface/src/ellipsoid-area.ts): the outline goes into the Lambert azimuthal equal-area projection on the WGS 84 ellipsoid, centered on the field (Snyder 1987, Map Projections: A Working Manual, USGS Professional Paper 1395, pp. 182–190), where an area on the map is the area on the ellipsoid, and is summed by the shoelace formula. The field and all its zones use the field's one projection center, so shared edges cancel and the pieces add up. A field's own acres in the app come from PostGIS, ST_Area(boundary::geography), also on the WGS 84 ellipsoid with geodesic edges; at a field's size a straight edge on the projection and a geodesic differ by well under a millimeter. The panel, the farm file and a later map page all read acres from the one FieldZones shape (apps/web/src/lib/terrain/field-zones.ts), so they cannot disagree, and each shows acres to the hundredth rounded by the largest remainder method so the rows add up to the field's acres as shown.
Worked outside the engine. A quadrangle 0.01° of longitude by 0.01° of latitude from 47° N, 97° W: integrating the ellipsoid's area element M(φ) N(φ) cos φ dφ dλ by Simpson's rule in a separate Python script (10,000 steps) gives 845,442.7925 m² (208.9135 ac), as does the closed form. The engine, with the parallels drawn at 400 points, matches to a square meter (ellipsoid-area.test.ts). On the real field Orwell S19 NW (docs/engineering/sample-field-candidates/orwell-s19-nw.geojson), the fixture gives 115.46 ac on the UTM 14N plane; UTM's scale there, 211 km east of the central meridian, is k = 0.9996 (1 + x²/2R²) = 1.000148, so the plane shows areas k² = 1.000296 too large and the ellipsoid holds 115.43 ac. The engine gives 115.43 ac within 0.015 ac (field-zones.test.ts).
Where the data runs out. Ground with no data is its own row, "No ground data", in the panel and in the file (ZONE_ID 0), and is never shared out among the zones. A field narrower than the smoothing still adds up, because smoothing runs on the whole terrain before the cut (tested on a 3 m strip at 2 m cells, and a 1.6 m strip at 1 m cells). Soil zones where no soil map is loaded say so and leave the field as no data. Each of the four kinds of zone is checked to add up to the field within 0.01 ac on the real field, with a hole, on a strip, and with the field running past the terrain.
Names and values (item 488)
Each zone takes a name of at most 40 characters, in any letters, accented or in any script (the owner, 2026-12-02; review finding G8), counted one per Unicode code point by the app (cleanZoneName) and the database (zone_value_set_valid, 20261202120800_zone_names_any_letter.sql) alike, with control characters dropped as they are typed and refused by the database. Forty characters are at most 160 bytes in UTF-8, inside the Shapefile's text column. The zone map page prints in a font of Latin letters only: a letter outside it prints as ? and the names table's title says so, while the Shapefile and GeoJSON keep every letter. It also takes up to three values in columns a person names (three is the narrow panel's choice, the plan's open decision). A column name is held to what a Shapefile's dBASE table allows as it is typed: letters, digits and underscores, upper case, ten characters at most, starting with a letter, and not one of the file's own columns. Values are numbers, of any sign, up to twelve characters and four decimals. Each column a person adds is written as a dBASE number column, one type to a column, so a program reading the file can sum, scale or color by it; a word for a zone belongs in its name. No program's format sets these rules (see exports.md, "Field zones as a Shapefile"). A zone with no value has an empty cell (a blank dBASE number, null in GeoJSON). The app suggests no rate and no value, and the fields are simply empty. Names and values are kept with the project in project_zone_values, one row per project and kind of zone.
6. Terrain cell size and change-area refusals (plan v3 item 430)
Every Lidar analysis card (landscape zones, topographic wetness, two-flight elevation change, change in an area, and heights above ground) and landscape-zone GeoJSON/Shapefile download displays the terrain cell size read from the terrain's record, or cell size not recorded when absent.
Two judgment thresholds, starting points that are neither cited nor yet measured against results (defined once in packages/surface/src/resolution.ts and proposed in docs/engineering/plan-v3-signoffs.md, Question 4, which no engineer has answered yet) apply to drawn change in an area polygons (checkChangeAreaResolution):
- Minimum width (
MIN_FEATURE_WIDTH_CELLS = 3cells, judgment): A drawn change-volume polygon whose rotation-invariant minimum width is narrower than3cells is refused with"needs finer terrain". - Minimum cells (
MIN_BASIN_CELLS = 9cells, judgment): A drawn change-volume polygon containing fewer than9valid cells is refused with"needs finer terrain". - Withholding: When refused, area, gained, lost, net volume, uncertainty range, and polygon fill shading are withheld, and the refusal states the cell count or width, the cell size, and to rebuild terrain at a finer cell size under Elevation data.
- Whole-terrain overlays: Landscape position zones (TPI), Topographic Wetness Index (TWI), full-terrain elevation change, and heights above ground evaluate the entire terrain raster (or point/line samples) and are not refused by the 3-cell / 9-cell feature rule. When a terrain record has no cell size, nothing is refused on coarseness. See
result-resolution.mdfor the full result table.