mcpField
V
verde

verde

github.com/steadfastasartData & databases7366 installsUpdated 6w ago
Repository

About verde

Verde is a Python skill for gridding scattered spatial data, intended for geoscientists and analysts. It combines multiple gridders with data reduction, trend handling, processing pipelines, and cross-validation.

Key features

  1. 01Spline, linear, and cubic gridding
  2. 02Block reduction of dense data
  3. 03Polynomial trend fitting and removal
  4. 04Composable processing pipelines
  5. 05Cross-validation for gridder selection
  6. 06Distance-based masking

Use cases

  1. 01Interpolate scattered elevation measurements
  2. 02Grid projected geographic coordinates
  3. 03Reduce clustered samples before gridding
  4. 04Validate interpolation choices
  5. 05Mask grid cells far from observations

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/steadfastasart/geoscience-skills --skill verde

After installing, type/verdein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
cross_validation.md
gridders.md
scripts/
grid_data.py

Details

From the project README

Verde - Spatial Data Gridding

Quick Reference

import verde as vd

# Basic gridding
spline = vd.Spline()
spline.fit(coordinates, values)  # coordinates = (lon, lat) tuple
grid = spline.grid(spacing=0.1)  # Returns xarray Dataset

# Access result
elevation = grid.elevation.values

# Save output
grid.to_netcdf('output.nc')

Key Classes

ClassPurpose
SplineBi-harmonic spline interpolation (smooth, good extrapolation)
LinearDelaunay triangulation (fast, no extrapolation)
CubicCubic interpolation (medium smoothness)
ChainPipeline of processing steps
BlockReduceDecimate data to block means/medians
TrendPolynomial trend fitting and removal
VectorGrid 2-component vector data

Essential Operations

Grid Scattered Data
coordinates = (longitude, latitude)  # Tuple of 1D arrays
values = elevation  # 1D array

spline = vd.Spline()
spline.fit(coordinates, values)
grid = spline.grid(spacing=0.1, data_names=['elevation'])
Project to Cartesian
import pyproj

projection = pyproj.Proj(proj='merc', lat_ts=data_lat.mean())
proj_coords = projection(longitude, latitude)

spline = vd.Spline()
spline.fit(proj_coords, values)
grid = spline.grid(spacing=1000)  # 1000m spacing
Block Reduce Large Datasets
import numpy as np

reducer = vd.BlockReduce(reduction=np.median, spacing=0.1)
coords_reduced, values_reduced = reducer.filter(coordinates, values)
Remove Trend Before Gridding
trend = vd.Trend(degree=2)  # Quadratic
trend.fit(coordinates, values)
residuals = values - trend.predict(coordinates)

# Grid residuals, then add trend back
Processing Pipeline
chain = vd.Chain([
    ('trend', vd.Trend(degree=1)),
    ('reduce', vd.BlockReduce(np.median, spacing=0.05)),
    ('spline', vd.Spline())
])
chain.fit(coordinates, values)
grid = chain.grid(spacing=0.01)
Cross-Validation
spline = vd.Spline()
scores = vd.cross_val_score(spline, coordinates, values, cv=5)
print(f"Mean R2: {scores.mean():.3f}")
Mask Far from Data
grid = spline.grid(spacing=0.1)
mask = vd.distance_mask(coordinates, maxdist=0.2, grid=grid)
grid_masked = grid.where(mask)

Grid Parameters

ParameterDescription
spacingGrid cell size (same units as coordinates)
region(west, east, south, north) bounds
shape(n_north, n_east) grid dimensions
adjust'spacing' or 'region' - which to adjust for exact fit

Gridder Comparison

GridderSpeedSmoothnessExtrapolation
SplineMediumHighGood
LinearFastLowNone
CubicFastMediumNone

When to Use vs Alternatives

Use CaseToolWhy
General spatial griddingVerdeML-style API, pipelines, cross-validation
Basic 1D/2D interpolationscipy.interpolateSimpler API, no spatial focus
Potential field griddingHarmonicaEquivalent sources designed for gravity/magnetics
Command-line batch griddingGMTPowerful CLI, good for automation scripts
Geostatistical interpolationscikit-gstat / pykrigeVariogram-based with uncertainty
Very large datasets (10M+ pts)GMT / GDALBetter memory handling at scale
Vector data (GPS velocities)Verde (Vector)Built-in 2-component vector gridding
Trend removal + griddingVerde (Chain)Pipeline combines steps cleanly

Choose Verde when: You need a Pythonic, scikit-learn-style API for gridding scattered spatial data with built-in cross-validation, trend removal, and pipelines. Ideal for exploratory analysis and reproducible workflows.

Choose scipy.interpolate when: You have a simple interpolation task without spatial coordinates, projections, or need for validation.

Choose GMT when: You need command-line batch processing of large datasets or are integrating with shell-based workflows and need surface or nearneighbor.

Common Workflows

Grid Scattered Spatial Data with Validation
  • Load scattered point data (coordinates + values)
  • Project geographic coordinates to Cartesian if needed
  • Inspect data distribution and identify clusters or gaps
  • Apply BlockReduce to decimate dense clusters
  • Remove regional trend with Trend(degree=1) or Trend(degree=2)
  • Cross-validate gridder parameters with cross_val_score()
  • Tune Spline(damping=...) or Spline(mindist=...) based on CV scores
  • Fit chosen gridder (Spline, Linear, or Cubic) on residuals
  • Grid onto regular spacing with .grid()
  • Add trend back to gridded residuals
  • Apply distance_mask() to clip extrapolation artifacts
  • Visualize grid with xarray plotting: grid.elevation.plot()
  • Save result to NetCDF with grid.to_netcdf()

Common Issues

IssueSolution
Poor extrapolationUse distance_mask() to mask far from data
Slow with large dataUse BlockReduce first
Regional trendsRemove with Trend before gridding
Wrong spacingCheck coordinate units (degrees vs meters)

References

Scripts

Comments

Markdown supported