Split Geometry
POST /api/forest/geo/operations
Divide a single Level 4 geometry into two new geometries using a cut polygon.
Authentication: RequiredPermissions:
forest-patrimony:UPDATE
Request Body
Operation type:
"split"UUID of the Level 4 geometry to split
GeoJSON geometry defining the cut area (Polygon or MultiPolygon)
Array of exactly 2 objects defining the resulting geometries:
New Level 4 code for the resulting geometry
Name for the resulting geometry
Level 4 type:
RODAL, PARCELA, ENUMERATION, UNIDAD_DE_MANEJO, CONUCO, OTRO_USODefaults to source geometry typeFSC certification status:
SI or NODefaults to source statusCurrent land use (must exist in
LandUseType configuration)Previous land use name for variation tracking
Date of the operation (ISO 8601 format). Defaults to current date.
Notes for patrimonial variation audit trail
Response
Operation type:
"split"UUID of the original (now inactive) geometry
Array of 2 UUIDs for the newly created geometries
Example: Split a Stand
cURL
Response
The original geometry is marked as
isActive: false and its forest_geometry_n4 record is closed with valid_to timestamp.Merge Geometries
POST /api/forest/geo/operations
Consolidate two adjacent Level 4 geometries into a single geometry.
Authentication: RequiredPermissions:
forest-patrimony:UPDATE
Request Body
Operation type:
"merge"Array of exactly 2 Level 4 UUIDs to merge. Both must:
- Belong to the same Level 3
- Be active (
isActive: true) - Belong to the user’s organization
Code for the resulting merged geometry
Date of the operation (ISO 8601 format). Defaults to current date.
Notes for patrimonial variation audit trail
Response
Operation type:
"merge"Array of 2 UUIDs for the original (now inactive) geometries
UUID of the newly created merged geometry
Example: Merge Two Stands
cURL
Response
Get Level 4 Geometry
GET /api/forest/geo/level4?id={level4Id}
Retrieve a Level 4 geometry with its current spatial data.
Authentication: RequiredPermissions:
forest-patrimony:READ
Query Parameters
UUID of the Level 4 geometry
Response
Level 4 UUID
Parent Level 2 UUID
Parent Level 3 UUID
Level 4 code
Level 4 name
Level 4 type (e.g.,
RODAL, PARCELA)FSC certification status:
SI or NOCurrent land use
Previous land use (if changed)
Total area in hectares (calculated from geometry)
GeoJSON geometry object (MultiPolygon in EPSG:4326)
Example: Fetch Geometry
cURL
Response
Update Level 4 Geometry
PATCH /api/forest/geo/level4
Update Level 4 attributes and/or geometry.
Authentication: RequiredPermissions:
forest-patrimony:UPDATE
Request Body
UUID of the Level 4 to update
New code (must be unique within Level 3)
New name
New type:
RODAL, PARCELA, ENUMERATION, UNIDAD_DE_MANEJO, CONUCO, OTRO_USOFSC status:
SI or NONew land use (triggers patrimonial variation if changed)
Previous land use for variation tracking
New geometry (Polygon or MultiPolygon). If provided:
- Old geometry is marked inactive
- New geometry is inserted
- Metrics (area, centroid) are recalculated
landUseChangeDateis updated
Response
Returns the updated Level 4 record.Example: Update Land Use
cURL
Delete Level 4 Geometry
DELETE /api/forest/geo/level4
Soft-delete a Level 4 geometry (marks as inactive).
Authentication: RequiredPermissions:
forest-patrimony:DELETE
Request Body
UUID of the Level 4 to delete
Response
Deletion confirmation message
Geospatial Processing Details
Split Operation Workflow
- Validate Source: Verify source Level 4 exists and is active
- Cut Geometry: Use PostGIS
ST_IntersectionandST_Differenceto split:- Part A = Intersection of source geometry with cut geometry
- Part B = Difference of source geometry and cut geometry
- Deactivate Source: Mark original geometry as inactive
- Create New Records: Insert two new Level 4 records with inherited attributes
- Store Geometries: Insert new geometries into
forest_geometry_n4 - Calculate Metrics: Compute area and centroid for both parts
- Track Variations: Create patrimonial variation records if land use changed
Merge Operation Workflow
- Validate Sources: Ensure both Level 4s exist, are active, and belong to same Level 3
- Union Geometries: Use PostGIS
ST_UnaryUnion(ST_Collect(...))to merge - Deactivate Sources: Mark both original geometries as inactive
- Create New Record: Insert merged Level 4 with combined attributes
- Store Geometry: Insert merged geometry into
forest_geometry_n4 - Calculate Metrics: Compute area and centroid for merged geometry
- Track Variation: Create patrimonial variation record
All geospatial operations run within database transactions to ensure atomicity.
Automated Metric Calculation
Whenever a geometry is created or updated, the following metrics are automatically calculated:- Total Area (Ha): Computed using PostGIS geography cast for accurate ellipsoidal calculations
- Centroid: Latitude and longitude of the geometric center (EPSG:4326)
- Land Use Totals: Organization-level land use surface totals are synchronized
Example: Area Calculation
Patrimonial Variation Tracking
All split, merge, and land use change operations automatically create records in theLandPatrimonialVariation table:
- Previous Land Use: Captured before the operation
- New Land Use: After the operation
- Affected Area (Ha): Calculated from geometry
- Variation Kind:
INCREMENTO(change) orSIN_CAMBIO(no change) - Status: Always
PENDIENTE(pending valuation) - Reference Values: Initialized to 0, updated later by valuation process
Error Responses
| Status Code | Error | Cause |
|---|---|---|
400 | Payload inválido | Missing required fields or invalid geometry type |
403 | No autorizado | Insufficient permissions or organization mismatch |
404 | Rodal no encontrado | Level 4 ID doesn’t exist or is inactive |
409 | Ya existe un rodal con ese código | Code uniqueness violation within Level 3 |
400 | Solo se pueden consolidar rodales del mismo Nivel 3 | Merge attempted across different Level 3s |
400 | La geometría se superpone con el rodal activo | New geometry overlaps with existing active geometry |
Related Endpoints
- Geospatial Import - Bulk import geometries from shapefiles
- Forest Patrimony - Manage forest hierarchy (Level 2/3/4/5)