Skip to main content

fbp

Field boundary prediction post-processing in Python.

fbp turns background, field, and boundary predictions into field instances. It includes BoundaryVote, the method behind the FTW Global Data 2nd Edition, along with watershed, connected-component, and published split-and-merge baselines.

Install

pip install ftw-fbp

The package imports as fbp.

For development:

git clone https://github.com/fieldsoftheworld/fbp.git
cd fbp
uv sync --extra dev

Use

A method takes a (H, W) class map and a (3, H, W) array of background, field, and boundary probabilities, and returns int32 instance labels with 0 as background. Each method is a frozen dataclass, so its settings can be written out and loaded again as plain data.

from fbp import BoundaryVote

method = BoundaryVote(
    foreground="not_background",
    seed_depth=0.01,
    min_line_support=0.3,
    min_area_m2=900,
)
instances = method(segmentation, probabilities, pixel_area_m2=9.0)

This method takes every pixel where field or boundary wins as foreground and floods 1 - p(boundary) from seeds at least 0.01 deep. It keeps a proposed split when at least 30% of the pixels on the dividing line favor boundary, and drops fields under 900 m². The class docstrings describe every option.

For rasters too large for one call, run_windowed processes core-sized windows with halo pixels of context on each side. The window whose core holds a field's centroid keeps that field, and copies of a field that crosses a window boundary are merged into one instance.

from fbp import run_windowed

instances = run_windowed(
    method,
    segmentation,
    probabilities,
    pixel_area_m2=9.0,
    core=8192,
    halo=512,
)

FTW Global Data 2nd Edition

fbp.FTW_2E is the setting used for the 2nd Edition field boundaries, run on 2.5 m probabilities:

from fbp import FTW_2E

instances = FTW_2E(segmentation, probabilities, pixel_area_m2=6.25)

Besides the BoundaryVote settings above (with min_line_support=0.5), it drops fields whose mean field probability is under 0.25. It then splits the looser foreground of pixels with field probability above 0.10 and adds each resulting field that the first pass covers less than half of, which recovers fields whose field probability rarely wins the argmax. That second pass is skipped when less than 2% of the looser foreground is uncovered. With fast=True, the probabilities are rounded to the 1/255 grid of the published uint8 rasters, and the watershed runs on integer levels. This needs the fast extra (SimpleITK and numba):

pip install 'ftw-fbp[fast]'

On the published probability rasters, FTW_2E reproduces the published raw outlines. It matches all 112 fields pixel for pixel on a 10 km window of tile 15TVG_0_0 (Iowa), and 647 of 648 fields (99.7% pixel for pixel) on tile 35MRT_0_0 (Rwanda).

Layout

src/fbp/core/      geometry and post-processing building blocks
src/fbp/methods/   the methods, one module each
tests/             package tests

A new method subclasses fbp.Method and implements split. Keep paper-specific evaluation, results, figures, and LaTeX outside this package.

Development

uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest

Metadata

Release files for ftw-fbp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ftw-fbp 0.1.0
File Size Uploaded Provenance Actions
ftw_fbp-0.1.0.tar.gz 34.4 kB Without provenance Details for ftw_fbp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ftw-fbp 0.1.0
File Interpreter ABI Platform Actions
ftw_fbp-0.1.0-py3-none-any.whl Python 3 none any Details for ftw_fbp-0.1.0-py3-none-any.whl

Total release size: 63.2 kB

Release files / ftw_fbp-0.1.0.tar.gz

Download URL ftw_fbp-0.1.0.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2cf1b1d7765459dfab9ed5e24927345c89cdf6160e38fdd8625c7aa5f63c5058
BLAKE2b-256 checksum
How to use checksums
a086379e5fca11b9c6dae78a279b8c2bc7eae1234a7a51a94009d445b29eaa2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ftw_fbp-0.1.0-py3-none-any.whl

Download URL ftw_fbp-0.1.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53fc04a6fedd6147cb7ac8a5b8d663f33958845c809b02082ec4fb9d1de72ee2
BLAKE2b-256 checksum
How to use checksums
054de8a32a6295d61a451537133c45641c0823b44d3648acd96948b24665ae36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ftw-fbp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page