Clip Worker

Processes clip operations to extract features within a boundary.

Overview

The clip worker extracts features from a dataset that intersect with a clipping boundary geometry.

Job Type

clip

Input Parameters

{
  "dataset_id": 123,
  "clip_geometry": {
    "type": "Polygon",
    "coordinates": [ ... ]
  },
  "output_dataset_id": 124
}

Parameters

  • dataset_id (required): Source dataset ID

  • clip_geometry (required): GeoJSON geometry for clipping boundary

  • output_dataset_id (required): Output dataset ID

Output

Creates a new dataset with clipped features:

  • Features that intersect the clipping boundary

  • Geometry clipped to boundary

  • Original attributes preserved

Algorithm

The worker uses PostGIS ST_Intersection to:

  1. Transform clipping geometry to dataset SRID

  2. Find features that intersect the boundary

  3. Clip geometries to boundary

  4. Store results in output table

Example

# Enqueue a clip job via API
curl -X POST "https://example.com/api/datasets_clip_run.php" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": 123,
    "clip_geometry": {
      "type": "Polygon",
      "coordinates": [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
    },
    "output_dataset_id": 124
  }'

Background Jobs

This analysis runs as a background job. The worker:

  1. Fetches queued clip jobs

  2. Validates input parameters

  3. Executes PostGIS clip queries

  4. Creates output dataset

  5. Marks job as completed

Performance Considerations

  • Processing time depends on dataset size and boundary complexity

  • Complex clipping boundaries may slow processing

  • Spatial indexes improve intersection performance

  • Consider simplifying geometries before clipping