Measuring the Philippine Coastline.

An investigation into fractal dimension algorithms (Box Counting, Rigid Yardstick, and Bending Yardstick) applied to Philippine islands and lakeshores.

View Latest Findings

Theoretical Framework

From Classical Geometry to Fractional Dimensions

In classical Euclidean geometry, topological dimensions are strictly integers: a zero-dimensional point ($D=0$), a one-dimensional line ($D=1$), a two-dimensional plane ($D=2$), and a three-dimensional volume ($D=3$). When a 1D line is scaled by a factor of $1/s$, it produces $N = s^1$ copies; a 2D square produces $N = s^2$ copies.

In 1918, Felix Hausdorff generalized dimension to non-integers: if scaling an object by 1/s yields N self-similar sub-units, its Hausdorff-Besicovitch Dimension is defined by N = (1/s)^D ⇒ D = log(N) / log(1/s).

Cantor Dust

D = log(2)/log(3) ≈ 0.6309

Formed by recursively deleting the middle third of a line segment. It has zero total length yet contains an uncountably infinite number of points, living strictly between $D=0$ and $D=1$.

Koch Snowflake

D = log(4)/log(3) ≈ 1.2618

Formed by replacing the middle third of each segment with an equilateral triangle ($N=4, s=1/3$). It encloses a finite, bounded area inside an infinitely long, nowhere-differentiable perimeter.

Sierpiński Gasket

D = log(3)/log(2) ≈ 1.5850

Constructed by cutting out the central triangle from an equilateral face ($N=3, s=1/2$). It has zero area but infinite boundary complexity spanning between a line ($D=1$) and a plane ($D=2$).

Hilbert Curve

D = log(4)/log(2) = 2.0000

A continuous, non-self-intersecting 1D path that twists infinitely to pass through every single point of a 2D unit square, achieving a space-filling dimension of exactly $D=2.0$.

The Coastline Paradox in Nature

Benoit Mandelbrot (1967) observed that natural geographical boundaries (islands, bays, and lakes) behave as statistical fractals. Unlike smooth geometric shapes ($D=1.0$), measuring a real coastline with a smaller yardstick reveals previously unresolved bays, coves, and promontories—causing the total measured length to diverge towards infinity. For Laguna de Bay ($D \approx 1.134$), measuring the fractal dimension provides a mathematically rigorous baseline: when human infrastructure (like road viaducts) straightens the perimeter, $D$ drops toward $1.0$, directly quantifying the loss of edge-effect microhabitats.

Algorithm Implementation

Scale ε = 40px | Intersecting Boxes N(ε) = 38Theoretical slope D = 1.261

Box Counting: A regular grid of box size ε covers the boundary. The algorithm counts every box intersecting the shoreline. As ε shrinks geometrically, the exponential growth of occupied boxes N(ε) yields the fractal dimension: D = - lim (log N / log ε).

Box Counting

A grid of boxes is placed over the shoreline. We count how many boxes intersect the curve. By exponentially shrinking the box size and plotting the counts logarithmically, the slope reveals the fractal dimension.

Rigid Yardstick

A virtual, rigid yardstick of length L "walks" along the shoreline from start to finish. The process is repeated with smaller yardsticks. The rate at which total steps increase reveals the dimension.

Bending Yardstick

An experimental method that allows the yardstick to bend precisely once at convex headlands. This aims to trace detail more accurately without conforming to every microscopic feature, reducing fractal inflation.

Core C/C++ Engine Implementation

To process high-resolution satellite boundaries with over 30,000 coordinate vertices across multi-scale geometric ladders, the estimator routines are compiled natively in C/C++ (src/fd.c) for maximum memory locality and zero-allocation execution.

C / C++ Native Engine
// Traverse grid cells intersected by segment a -> b (Amanatides-Woo DDA)
static void traverse(hset *h, pt a, pt b, double s) {
    long ix = (long)floor(a.x / s), iy = (long)floor(a.y / s);
    long ix1 = (long)floor(b.x / s), iy1 = (long)floor(b.y / s);
    hs_insert(h, cell_key(ix, iy));
    
    double dx = b.x - a.x, dy = b.y - a.y;
    int stepx = dx > 0 ? 1 : -1, stepy = dy > 0 ? 1 : -1;
    double tmx = dx != 0 ? ((stepx > 0 ? (ix + 1) * s - a.x : ix * s - a.x) / dx) : 1e300;
    double tmy = dy != 0 ? ((stepy > 0 ? (iy + 1) * s - a.y : iy * s - a.y) / dy) : 1e300;
    double tdx = dx != 0 ? s / fabs(dx) : 1e300;
    double tdy = dy != 0 ? s / fabs(dy) : 1e300;
    
    // March across cell boundaries until reaching endpoint
    while (ix != ix1 || iy != iy1) {
        if (tmx < tmy) { if (tmx >= 1.0) break; ix += stepx; tmx += tdx; }
        else           { if (tmy >= 1.0) break; iy += stepy; tmy += tdy; }
        hs_insert(h, cell_key(ix, iy));
    }
}

Review of Related Literature

Our approach builds heavily on established computational methods for self-similar boundaries. The Box Counting baseline is standard, while our Rigid Yardstick implementation follows the classic digital compass walk by Shelberg, Moellering, and Lam (1982). Our experimental Bending Yardstick sits computationally between the standard walking family and the constant-deviation variable-step (CDVS) convex-hull methods pioneered by Normant and Tricot (1991).

Locally, Philippine prior art is sparse. Alova (2025) measured the Negros Island coastline at D = 1.018 using Box Counting and coarse GADM vectors. However, there are no published archipelago-wide values, nor studies utilizing precise satellite-derived masks for Philippine lakes (like Laguna de Bay or Taal Lake). This project represents the first multi-feature algorithm-comparison fractal study tailored specifically for Philippine topographies.

Data Pipeline

Spectral Processing

Dual-Lake NDWI Compositing

Sentinel-2 Harmonized Level-2A surface reflectance is processed through normalized difference water index (NDWI) thresholding. A 7-date temporal median stack and a 150m morphological kernel remove transient clouds, hyacinth mats, and tributary river branches.

Machine Learning QA

Hugging Face & SAMGeo Cross-Validation

To verify our NDWI thresholds against semantic edge cases, we integrated the Hugging Face 6-band Sentinel-2 UNet++ model (giswqs/s2-water-unetplusplus-efficientnet-b4) and Meta's SAMGeo (Segment Anything for Geospatial). These deep neural networks served as an independent cross-check to confirm that turbid shallows and fishpens were not erroneously classified as land.

Cloud Automation

10-Year Longitudinal Engine

An automated pipeline streaming Cloud-Optimized GeoTIFFs (COGs) via AWS Earth Search computes historical monthly Fractal Dimensions across a 10-year baseline (2017–2026), providing an empirical baseline prior to LLRN road construction.

01

AWS Earth Search STAC Streaming

Direct spatial subset streaming of Sentinel-2 L2A 10m bands (B2, B3, B4, B8, B11, B12) and Scene Classification Layer (SCL) without downloading heavy .SAFE archives.

02

Cloud & Shadow Filtering (SCL Mask)

Pixels categorized as cloud high/medium probability, thin cirrus, or cloud shadow are flagged as invalid (NaN) to prevent atmospheric edge artifacts.

03

7-Date Temporal Median Stacking

Stacking 7 observations per month and taking the pixel-wise nanmedian() synthesizes a pristine, cloud-free optical composite by replacing cloud gaps with clear water views.

04

Normalized Difference Water Index (NDWI)

NDWI = (Green - NIR) / (Green + NIR). Water pixels with index > 0.00 are segmented into a continuous binary lake mask.

05

150m Morphological Opening (River-Snipping)

Applying mathematical morphology (scipy.ndimage.binary_opening with a 15×15 kernel) snips narrow inland river channels (like the Napindan River) to avoid infinite tracer recursion.

06

C Binary Fractal Estimation Engine (./bin/fd)

Optimized C routines execute Box Counting grids, Rigid Divider Compass walks, and Bending Yardstick sweeps across 30,000+ coordinates to compute the fractal dimension ($D$).

Findings

Multi-Temporal Composite Verification

Single-date satellite scenes in the tropics suffer from moving cumulus clouds that artificially slice lake water into fragmented boundaries. Our 7-date temporal median stacking eliminates all cloud interference, extracting the continuous, noise-free geometry of Laguna de Bay for mathematical fractal measurement.

Sentinel-2 clean boundary overlay over March 2026 satellite imagery

Laguna de Bay (March 2026). The orange composite boundary traces the real outer shoreline without getting distorted by optical cloud cover.

Synthesized cloud-free multi-temporal median composite

Synthesized Cloud-Free Median Composite. Multi-temporal pixel median stacking replaces cloud patches over water with clear observations across the month.

LLRN Ecological Impact

Measuring the Ecological Impact of the Laguna Lakeshore Road Network

Laguna de Bay is a vital ecological and economic resource in the Philippines. The ongoing construction of the Laguna Lakeshore Road Network (LLRN) risks permanently altering the lake's natural shoreline. Such geometric alterations can impact water flow, stagnation, and local ecosystems, leading to direct public health consequences for lakeshore communities through altered disease vector habitats.

To measure this impact, Sentinel-2 Harmonized Level-2A satellite imagery was processed using a Normalized Difference Water Index (NDWI) pipeline. To eliminate moving clouds and floating water hyacinths, a 7-date temporal median composite was applied, combined with a 150m morphological kernel to exclude narrow river inlets. The fractal dimension (FD) of the extracted shorelines was computed using Box Counting, Rigid Yardstick, and Bending Yardstick algorithms implemented in C.

The robust temporal compositing method revealed the true, noise-free fractal geometry. For Laguna de Bay, the Fractal Dimension remained completely stable across the 12-month period (D = 1.134 to D = 1.131, a statistically insignificant change of just -0.003). Computations for the Taal Lake control group were successfully executed, establishing a pristine natural baseline of D = 1.170, proving the pipeline's scalability across multiple topological boundaries.

Ultimately, the stability of Laguna Lake's fractal dimension confirms that the offshore LLRN infrastructure has not yet physically altered the lake's boundary as of early 2026. As concrete viaducts and embankments are constructed over the coming years, this open-source methodology provides a rigorous framework to continuously monitor the creeping simplification of shorelines and the inevitable loss of edge-effect habitats.

Shoreline Geometry Analysis

Full Lake Shoreline Comparison

Full lake shoreline overlay. Cyan: March 2025 baseline. Orange: March 2026 composite. The two boundaries are nearly identical, confirming geometric stability.

Automated Drift Analysis

Spatial drift analysis. Extreme shifts in the southern bay are due to natural shallow mudflat exposure during dry season, not land reclamation.