Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
geoenrich
geoenrich is a Rust command-line tool that adds geospatial attributes to a
table of points. Give it a file with longitude and latitude columns and it
appends any of:
- coast: distance to the nearest shoreline (GSHHG).
- depth: bathymetric depth at the point (GEBCO).
- sea: the sea or ocean name at the point (IHO Sea Areas).
- place: the nearest country and municipality (Natural Earth + GISCO).
- nearest: the nearest location in a second table you supply, and the distance to it (any two sets, for example measurements and fish farms).
It reads and writes Parquet (default), CSV, TSV, and the gzip variants csv.gz
and tsv.gz. Each command reduces the input to unique rounded locations,
processes those in parallel, and joins the results back onto every row, so a file
with millions of rows but few distinct positions is cheap to enrich.
Status: all five modules are implemented and tested:
coast(nearest GSHHG shoreline by projected R-tree lookup),depth(GEBCO grid lookup),sea(IHO point in polygon with a nearest fallback),place(nearest Natural Earth country and GISCO LAU municipality), andnearest(nearest point of a caller-supplied table by unit-sphere R-tree). SeeCLAUDE.mdfor the algorithm and caveats per module.
Install
# binary at target/release/geoenrich
The depth command reads GEBCO NetCDF and links the HDF5 / NetCDF C libraries,
so you need the dev headers (as with ctddump):
# Ubuntu / Debian
# macOS
Usage
Every command shares these options:
| Option | Default | Meaning |
|---|---|---|
-o, --output <FILE> |
<stem>.<command>.<input format> |
Output file |
--in-format <FMT> |
inferred, else parquet | parquet, csv, tsv, csv.gz, tsv.gz, auto |
--out-format <FMT> |
inferred, else parquet | same set |
--overwrite |
off | Replace clashing output columns instead of failing |
--lon-col <NAME> |
longitude |
Longitude column |
--lat-col <NAME> |
latitude |
Latitude column |
--decimals <N> |
3 |
Rounding applied before de-duplicating |
-t, --threads <N> |
all cores | Worker threads |
-c, --config <TOML> |
none | Config file (CLI flags override it) |
The coast, sea, and place commands also take region options: a --region
preset (global, baltic, norway, arctic, atlantic, europe,
mediterranean) or explicit --min-lon/--max-lon/--min-lat/--max-lat, plus
--proj-lon0/--proj-lat0 for the distance projection center. The default region
is the whole globe.
The nearest command instead takes a second table (--to), the set of named
locations to measure the distance to. Its coordinate columns default to
longitude/latitude (--to-lon-col/--to-lat-col) and the name column to
name (--name-field). Distances are great-circle (exact anywhere on the
globe, so this command has no region or projection center), in kilometers by
default or meters with --unit m.
Examples
# Distance to coast, GSHHG resolution 'f', result in kilometers
# Bathymetric depth from a GEBCO grid, reading and writing gzipped CSV
# Sea name, cropping the reference data to the Norway region
# Nearest country and municipality
# Nearest fish farm to each measurement, distance in km
Run geoenrich <command> --help for the full interface.
To run several modules over one input and get a single file with all their new
columns, use scripts/enrich.sh, which chains the selected modules and removes
the intermediate files:
Run scripts/enrich.sh --help for all options.
Output columns
| Command | Appended columns |
|---|---|
coast |
dist_to_coast (rename with --column) |
depth |
bathymetry (rename with --column) |
sea |
sea_name (rename with --column) |
place |
country, country_code, municipality |
nearest |
nearest_name, nearest_dist (rename with --name-column / --dist-column) |
Data
The reference datasets are downloaded separately (they are large and not
bundled). scripts/download_data.sh fetches and unpacks any of them into
./data/, one sub-directory per source, matching the example paths above:
# GSHHG, GEBCO, Natural Earth, and GISCO need no details
# the Marine Regions (IHO) download sits behind a short form
Run scripts/download_data.sh --help for all options. Sources:
- GSHHG shorelines: https://www.soest.hawaii.edu/pwessel/gshhg/
- GEBCO bathymetry: https://www.gebco.net/
- IHO Sea Areas: https://www.marineregions.org/
- Natural Earth: https://www.naturalearthdata.com/
- Eurostat GISCO LAU: https://ec.europa.eu/eurostat/web/gisco
License
MIT.