# Erase Analysis Worker

Processes erase operations to remove features using another dataset.

## Overview

The erase analysis worker removes portions of features from an input dataset that overlap with features in an erase dataset.

## Job Type

`erase_analysis`

## Input Parameters

```json
{
  "input_dataset_id": 123,
  "erase_dataset_id": 124
}
```

### Parameters

- `input_dataset_id` (required): Input dataset ID
- `erase_dataset_id` (required): Erase dataset ID

## Output

Creates a new dataset with erased features:

- Features with erased portions removed
- Remaining geometry after erase operation
- Original attributes preserved

## Algorithm

The worker uses PostGIS `ST_Difference` to:

1. Find features that intersect the erase dataset
2. Calculate difference (input - erase)
3. Remove empty geometries
4. Store results in output table

## Example

```bash
# Enqueue an erase analysis job via API
curl -X POST "https://example.com/api/analysis_erase_run.php" \
  -H "Content-Type: application/json" \
  -d '{
    "input_dataset_id": 123,
    "erase_dataset_id": 124
  }'
```

## Background Jobs

This analysis runs as a background job. The worker:

1. Fetches queued `erase_analysis` jobs
2. Validates input parameters
3. Executes PostGIS erase operations
4. Creates output dataset
5. Marks job as completed

## Performance Considerations

- Processing time depends on dataset sizes and overlap
- Complex geometries may slow processing
- Spatial indexes improve intersection performance
- Consider simplifying geometries before erasing

## Related Documentation

- [Erase Analysis Tool](../analysis-tools/erase.md)
- [Analysis API](../api/analysis.md)
- [Workers Overview](index.md)

