AR1/docs/workers/raster_clip.md

88 lines
2.0 KiB
Markdown

# Raster Clip Worker
Processes raster clip operations to extract raster data within a boundary.
## Overview
The raster clip worker extracts raster data that intersects with a clipping boundary geometry.
## Job Type
`raster_clip`
## Input Parameters
```json
{
"raster_dataset_id": 125,
"clip_geometry": {
"type": "Polygon",
"coordinates": [ ... ]
},
"output_dataset_id": 126
}
```
### Parameters
- `raster_dataset_id` (required): Source raster dataset ID
- `clip_geometry` (required): GeoJSON geometry for clipping boundary
- `output_dataset_id` (required): Output raster dataset ID
## Output
Creates a new raster dataset with clipped data:
- Raster data within the clipping boundary
- Original raster properties preserved
- Proper spatial reference maintained
## Algorithm
The worker uses PostGIS raster functions to:
1. Transform clipping geometry to raster SRID
2. Clip raster to boundary using `ST_Clip`
3. Store clipped raster in output table
4. Update raster metadata
## Example
```bash
# Enqueue a raster clip job via API
curl -X POST "https://example.com/api/raster_clip_run.php" \
-H "Content-Type: application/json" \
-d '{
"raster_dataset_id": 125,
"clip_geometry": {
"type": "Polygon",
"coordinates": [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
},
"output_dataset_id": 126
}'
```
## Background Jobs
This analysis runs as a background job. The worker:
1. Fetches queued `raster_clip` jobs
2. Validates input parameters
3. Executes PostGIS raster clip operations
4. Creates output raster dataset
5. Marks job as completed
## Performance Considerations
- Processing time depends on raster size and boundary complexity
- Large rasters may require significant memory
- Consider resampling for very large rasters
- Clipping boundaries should match raster resolution
## Related Documentation
- [Raster Tools](../analysis-tools/raster.md)
- [Analysis API](../api/analysis.md)
- [Workers Overview](index.md)