Communitygithub.com

Cadastral to Vector

Convert cadastral map PNGs to vector polygon feature classes (FileGDB/Shapefile). Automatic CGCS2000 3-degree zone detection, OCR extraction of boundary point coordinates, dual arcpy/GDAL backend, and area-based self-check.

What is Cadastral to Vector?

This skill enables AI agents to convert cadastral maps (PNG/JPG) into polygon feature classes suitable for property registration in FileGDB or Shapefile format. It automates the entire workflow: OCR extraction of boundary point coordinate tables from the image, automatic detection of the CGCS2000 Gaussian projection zone (EPSG code), and coordinate axis orientation determination. The skill then constructs closed polygons from the ordered coordinates and writes them to a database with attribute fields. It includes an area self-check that compares the computed polygon area against the on-map area, flagging discrepancies over 0.5%. The skill supports two backends—arcpy (ArcGIS Pro) as the primary and GDAL as a fallback. A key requirement is that all automated decisions (zone number, axis assignment, coordinate table) must be confirmed by the user before final processing, ensuring property-grade accuracy.

Works with~Claude Code~Codex CLI~Cursor
npx skills add edcfoshan/cadastral-to-vector

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does Cadastral to Vector do?

Convert cadastral map PNGs to vector polygon feature classes usable for property registration. Pipeline: OCR extracts boundary point coordinate table → automatic detection of CGCS2000 3-degree zone number and coordinate axes → ordered points form closed polygons → write to FileGDB/Shapefile, with on-map area used for self-check.

When to Use

  • Cadastral map / parcel map (PNG/JPG) → GDB or Shapefile polygon feature class
  • Existing boundary point coordinate table text → polygon feature class
  • Need to determine CGCS2000 Gaussian projection zone number (EPSG)
  • Property registration-grade accuracy (coordinates precise, topology closed)

Workflow

  1. Confirm Input: Cadastral map PNG (primary) or coordinate table text/CSV (fallback). Ask whether property registration-grade precision is required.
  2. OCR Coordinates + Attributes:
    • First choice: use analyze_image MCP (multimodal, most accurate). Prompt to extract coordinate table + attributes (rightful owner / parcel number / area / use / adjacent boundaries) digit by digit exactly. Mark unclear items as "unclear"—do not guess.
    • If no MCP, run scripts/ocr_coords.py --method auto (paddleocr→tesseract).
    • If neither works, ask the user to manually transcribe.
  3. Present Coordinate Table for User Review: All OCR results must be shown to the user for individual verification (property-grade data cannot be blindly trusted). Save verified coordinates as pts.txt (one line per row: point_id, coord_A, coord_B, in boundary connection order).
  4. Automatic Zone/Axis/CRS Detection: Run scripts/coords_to_feature.py --coords pts.txt --source <image> --detect-only, or follow the rules:
    • Column with a zone prefix (8-digit number, first 2 digits between 25-45) = easting; the other column = northing.
    • Zone N → EPSG = 4488 + N, central meridian = 3N.
    • Neither column has a prefix → ask the user for zone number + axis order.
  5. Detection Results Must Be Confirmed by User (mandatory step): Show zone number / central meridian / EPSG / easting column / northing column. Proceed only after user confirmation.
  6. Attribute Fields: Ask the user if they want business fields (rightful owner / parcel number / area etc., checked from OCR results); source_file field is added automatically (records the source file path for traceability).
  7. Write GDB/Shapefile: Run scripts/coords_to_feature.py --out xxx.gdb --fig-area <on_map_area> [--attrs-json ...]. arcpy preferred; fallback to GDAL if arcpy unavailable; fallback to Shapefile if GDB cannot be written.
  8. Self-Check + Delivery: Check the script's output for area self-check (PASS/FAIL); if FAIL, review coordinates. Deliver .gdb/.shp, note the attribute table includes source_file.

Dependencies

  • Python 3
  • Write GDB: arcpy (ArcGIS Pro with arcgispro-py3) or GDAL/osgeo ≥3.6 (OpenFileGDB driver can create)
  • OCR: analyze_image MCP (preferred) / paddleocr / tesseract(chi_sim) / manual transcription

Scripts

  • scripts/coords_to_feature.py — coordinate table → GDB/shp polygon feature class (auto detection + arcpy/GDAL fallback + source_file + area self-check)
  • scripts/ocr_coords.py — PNG → coordinate table + attributes (paddleocr/tesseract fallback chain)

Notes

  • Property Registration Grade: A single wrong coordinate is a critical error. All OCR/auto-detection results must be user-verified.
  • Area Self-Check: Calculated area vs. on-map area. Warn if error > 0.5%. Swapped axes leave area unchanged—self-check cannot catch this; rely on step 5 (manual axis confirmation).
  • Multiple Parcels: Currently supports single parcel (one map, one polygon); multi-parcel support is future work.
  • Shapefile field names are limited to 10 bytes; Chinese business field names will be truncated. Recommend GDB or English field names.

Related Skills