Skip to content

Add ArcGIS Online export script and embeddable chart pages#97

Open
michaelmfoley wants to merge 3 commits into
mainfrom
storymap-embeds
Open

Add ArcGIS Online export script and embeddable chart pages#97
michaelmfoley wants to merge 3 commits into
mainfrom
storymap-embeds

Conversation

@michaelmfoley

Copy link
Copy Markdown
Collaborator

Summary

Tooling to build an ArcGIS StoryMap from the 2026-04 CSO × EJ analysis (companion to #96, but independent of it).

analysis/export_arcgis.py

Packages ArcGIS-Online-ready layers into a gitignored arcgis_export/ directory (run from analysis/, needs only pandas + geopandas, both already in amend_python; not part of CI):

  • cso_outfalls_2022_2025.csv — 193 outfall points with clean field names (fixes the permitee misspelling at the export boundary) and total discharge/counts for the through-2025 window
  • watersheds_ej_discharge.geojson / towns_ej_discharge.geojson / block_groups_ej_discharge.geojson — MassGIS/Census polygons joined with EJSCREEN indicators (converted to 0–100 percents) and discharge totals
  • optional --include-2011 NECIR baseline (renames the digit-leading columns AGO rejects)
  • a generated README.md data dictionary with units, caveats, suggested AGO field aliases, and attribution

Built-in checks: feature counts (193/32/351/4,982), CRS = EPSG:4326, MA bounding box, and volume conservation across aggregation levels (all agree at 19,348.3 Mgal; town totals are ~7% lower because some outfalls have unknown town assignments — documented in the README).

Data fix: the source outfall list has one row (Haverhill HAV021B) with latitude/longitude swapped (lat=-71.08, lon=42.77); the export detects and repairs swapped pairs and logs them. This same row presumably renders off-map in the existing Plotly maps — may be worth fixing upstream in the outfall ingest at some point.

docs/embeds/

Standalone, iframe-able wrapper pages for eight of the post's charts (for embedding in ArcGIS StoryMaps or elsewhere). The chart includes in docs/_includes/charts/ are already complete self-contained HTML documents — Jekyll just doesn't serve _includes/ — so each page is 4 lines: front matter + the include. An index.md documents usage and links all eight. Once merged these serve at https://openamend.org/embeds/<name>.html and update automatically whenever the pipeline regenerates the underlying charts.

Testing

  • Export script run end-to-end; outputs verified with an independent geopandas read-back (feature counts, CRS, bounds, spot-check of MERRIMACK EJ values against the source CSV)
  • Embed pages validated by simulating the Jekyll render (front matter stripped, include substituted, {% raw %} unwrapped) — each result is a complete HTML document with its Chart.js CDN reference; the include-path pattern is identical to what the posts already use in production

🤖 Generated with Claude Code

michaelmfoley and others added 3 commits July 8, 2026 17:01
Support building an ArcGIS StoryMap from the 2026-04 CSO/EJ analysis:

- analysis/export_arcgis.py packages hosted-feature-layer-ready files
  into a gitignored arcgis_export/ directory: CSO outfall points
  (2022-2025 window), watershed/town/block-group polygons joined with
  EJSCREEN EJ indicators (as 0-100 percents) and discharge totals, an
  optional 2011 NECIR baseline, and a README data dictionary with
  suggested field aliases. Includes volume-conservation and geometry
  assertions, and repairs swapped lat/lon pairs found in the source
  outfall list (e.g. Haverhill HAV021B).
- docs/embeds/ serves standalone, iframe-able wrapper pages for eight
  post charts (the chart includes are already self-contained HTML
  documents; Jekyll just doesn't serve _includes/). An index page
  documents usage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AGO's hosted-feature-layer publisher fails with "There was an error
publishing the service" on the towns and watersheds layers as previously
written: the MapShaper-simplified MassGIS sources carry non-RFC ring
winding and one self-intersecting polygon (WAYLAND). Repair invalid
geometries with buffer(0) and write all polygon layers with RFC7946=YES
(enforced ring winding, 7-decimal precision, no legacy "crs" member).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ArcGIS Online's GeoJSON importer still rejects the MassGIS-derived towns
and watersheds layers after RFC 7946 normalization and geometry repair
(the block-group layer, from Census cartographic boundaries, publishes
fine — including null attributes, ruling those out). Sidestep the GeoJSON
parser entirely: write all three polygon layers into one
amend_polygons.gdb.zip via GDAL's OpenFileGDB driver (promote_to_multi,
since FileGDB layers hold a single geometry type), verify by read-back,
and document it as the recommended AGO upload. GeoJSON outputs are kept
for non-Esri tools.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant