{"data":{"slug":"github-datopian-portaljs-skills-portaljs-add-geo-b743860c81b4","title":"Add Geo Data to PortalJS","summary":"Automatically ingest and process geospatial files (GeoJSON, Shapefile, GeoPackage, KML\/KMZ, FlatGeobuf, CSV-with-geometry) into a PortalJS portal on the user's own machine with no server. Normalizes CRS to EPSG:4326, derives a PMTiles render tier and a GeoParquet query tier, pushes all three artifacts to Cloudflare R2 via Git LFS, and appends one dual-tier datasets.json entry the showcase auto-renders.","url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-geo-b743860c81b4","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-datopian-portaljs-skills-portaljs-add-geo-b743860c81b4","markdown_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-geo-b743860c81b4.md","download_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-geo-b743860c81b4\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Prerequisites: A scaffolded `portaljs-catalog` portal with `components\/MapPreview.tsx` and `components\/GeoQuery.tsx` (PR #1647 or later). Native CLIs on the user's machine: GDAL (`ogr2ogr`, `ogrinfo`), tippecanoe, and duckdb (with the `spatial` extension). Arc credentials for the Git-LFS \u2192 R2 push (the same token `portaljs-deploy` resolves), or an OSS self-hosted Giftless.","instructions":"---\nname: portaljs-add-geo\ndescription: Auto-ingest a geospatial file (GeoJSON, Shapefile, GeoPackage, KML\/KMZ, FlatGeobuf, CSV-with-geometry) into a PortalJS portal on the user's own machine, with no server. Normalizes CRS to EPSG:4326, derives a PMTiles render tier and a GeoParquet query tier, pushes all three artifacts to Cloudflare R2 via Git LFS, and appends one dual-tier datasets.json entry the showcase auto-renders. Use when the source is a vector geo format that needs a map or spatial-query view.\nallowed-tools: Read, Write, Edit, Bash(ogr2ogr:*), Bash(ogrinfo:*), Bash(tippecanoe:*), Bash(duckdb:*), Bash(git:*), Bash(curl:*), Bash(npx:*), Bash(node:*), Bash(mkdir:*), Bash(cp:*), Bash(wc:*), Bash(command:*), WebFetch\nversion: 1.0.0\nauthor: Datopian <hello@datopian.com>\nlicense: MIT\ncompatibility: Claude Code with PortalJS portals (Next.js 14, React 18\/19, Node 18+). Requires native GDAL, tippecanoe, and duckdb on the user's machine (macOS or Linux\/WSL). Runs from any project via the plugin, a personal ~\/.claude\/commands install, or a portaljs clone.\ntags:\n  - portaljs\n  - data-portal\n  - geospatial\n  - pmtiles\n  - geoparquet\n  - duckdb\n---\n\n# PortalJS \u2014 Add Geo\n\n## Overview\n\nTurn one geospatial upload into a **dual-tier** PortalJS dataset entirely on the user's\nmachine \u2014 **no server-side container compute**, keeping the zero-backend bet end-to-end.\nFrom a single source the skill derives two serverless tiers plus the preserved original:\n\n- **PMTiles** (render tier) \u2014 a vector-tile archive `<MapPreview>` renders with MapLibre GL\n  over HTTP range requests; any dataset size pans and zooms with no tile server.\n- **GeoParquet** (query tier) \u2014 a GeoParquet 1.1 file (covering `bbox` column, Hilbert-sorted)\n  `<GeoQuery>` runs spatial SQL over in place via DuckDB-Wasm.\n- **Original** \u2014 the untouched upload in its native CRS, kept downloadable.\n\nAll three land on Cloudflare R2 (Git LFS \u2192 Giftless), and the skill appends **one**\n`datasets.json` entry whose `resources[]` match the shape the showcase auto-renders (the\n`@reference\/world-boundaries` demo, PR #1647): `pmtiles` \u2192 `<MapPreview>`, `geoparquet` \u2192\n`<GeoQuery>`, original \u2192 download. No page edits are needed. It automates the manual\n`tippecanoe`\/`duckdb` recipes in the template README.\n\n## Prerequisites\n\n- A scaffolded `portaljs-catalog` portal whose template ships `components\/MapPreview.tsx` and\n  `components\/GeoQuery.tsx` (PR #1647 or later).\n- Native CLIs on the user's machine: **GDAL** (`ogr2ogr`, `ogrinfo`), **tippecanoe**, and\n  **duckdb** (with the `spatial` extension). macOS: `brew install gdal tippecanoe duckdb`;\n  Debian\/Ubuntu: `apt-get install gdal-bin duckdb` + tippecanoe (apt or build from source);\n  Windows: use WSL. The skill hard-stops with the install hint if any is missing.\n- Arc credentials for the Git-LFS \u2192 R2 push (the same token `portaljs-deploy` resolves), or\n  an OSS self-hosted Giftless.\n\n## Instructions\n\nThe canonical, full step-by-step workflow is\n[`.claude\/commands\/portaljs-add-geo.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-geo.md)\n\u2014 the single source of truth. Read and follow it when executing. Summary:\n\n1. Gather input \u2014 source (geo file path or URL), portal directory, namespace. Interview if\n   missing; never dead-end.\n2. Detect the native tools (`ogr2ogr`, `tippecanoe`, `duckdb` + `spatial`). Any missing \u2192\n   print the per-OS install and stop.\n3. Validate the portal directory and confirm the geo showcase components exist.\n4. Fetch (if URL) and detect the input format; reject raster and bare `.shp`.\n5. Preserve the original, then normalize to EPSG:4326 GeoJSON with `ogr2ogr -t_srs EPSG:4326`.\n6. Apply the size escape hatch (measure normalized-GeoJSON bytes): warn \u2265 500 MB; skip PMTiles\n   and emit GeoParquet-only > 2 GB (documented, never silent).\n7. Derive PMTiles with `tippecanoe -zg --drop-densest-as-needed`.\n8. Derive GeoParquet with `duckdb` \u2014 covering `bbox` STRUCT + `ST_Hilbert` order; verify a\n   range read.\n9. Track all three files with Git LFS, mint an Arc JWT, push to R2, prune, and build the\n   absolute `data.portaljs.com` URLs.\n10. Append one dual-tier `datasets.json` entry (`pmtiles` + `geoparquet` + original resources).\n11. Verify: `npx tsc --noEmit` and a `Range:` 206 check on the R2 URL.\n12. Report the tiers, manifest entry, and showcase route.\n\n## Output\n\n- **Created:** `data\/<slug>.pmtiles`, `data\/<slug>.parquet`, `data\/<slug>.<origext>` (all\n  LFS-tracked \u2192 R2); `data\/<slug>.4326.geojson` (intermediate; can be pruned).\n- **Modified:** `datasets.json` (one dual-tier entry appended); `.gitattributes` (LFS tracking).\n- **Verified:** `npx tsc --noEmit` passes; the R2 URLs answer HTTP 206 range reads.\n- **Result:** `\/@<namespace>\/<slug>` renders the PMTiles map and the GeoParquet spatial-query\n  panel together, with no page edits.\n\n## Error Handling\n\n| Symptom | Cause | Fix |\n| --- | --- | --- |\n| `MISSING_TOOLS` | `ogr2ogr`\/`tippecanoe`\/`duckdb` (or duckdb `spatial`) absent | Print the per-OS install line and stop; re-run after installing. |\n| `UNSUPPORTED_FORMAT` | Raster `.tif`\/`.tiff` (COG tier, later phase) | Use `portaljs-add-dataset` for tabular; await the COG phase. |\n| `SHAPEFILE_NOT_ZIPPED` | Bare `.shp` with no siblings | Zip the whole `.shp\/.dbf\/.shx\/.prj` set and pass the `.zip`. |\n| `MULTI_LAYER` | GPKG\/KML with more than one layer | List layers and ask which to ingest; pass the layer name. |\n| `REPROJECTION_FAILED` | `ogr2ogr` error, often a missing `.prj` | Show stderr; re-run with `-s_srs EPSG:<code>`. |\n| `EMPTY_OUTPUT` | Normalized GeoJSON has 0 features | Check the geometry column \/ CRS of the source. |\n| `TILING_FAILED` \/ `GEOPARQUET_FAILED` | tippecanoe or duckdb non-zero | Show stderr; for very large inputs see the size escape hatch. |\n| `LFS_PUSH_FAILED` | Missing\/expired Arc token or unset `lfs.url` | Re-mint the JWT (see `portaljs-deploy`); confirm `git config lfs.url`. |\n\n## Examples\n\n### Example 1 \u2014 Ingest a GeoJSON into both tiers\n\n```\n\/portaljs-add-geo source=.\/data\/rivers.geojson name=\"World Rivers\" namespace=reference\n```\n\n### Example 2 \u2014 Zipped Shapefile from a URL\n\n```\n\/portaljs-add-geo source=https:\/\/example.com\/admin-boundaries.zip slug=admin-boundaries\n```\n\n### Example 3 \u2014 GeoPackage with an explicit layer and namespace\n\n```\n\/portaljs-add-geo source=.\/data\/census.gpkg slug=census-tracts namespace=statistics\n```\n\n## Resources\n\n- Full workflow: [`.claude\/commands\/portaljs-add-geo.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-geo.md)\n- Flags, thresholds, and the dual-tier manifest shape: [`references\/reference.md`](references\/reference.md)\n- Related skills: `portaljs-add-dataset`, `portaljs-add-map`, `portaljs-add-resource`, `portaljs-deploy`\n- tippecanoe: <https:\/\/github.com\/felt\/tippecanoe> \u00b7 DuckDB spatial: <https:\/\/duckdb.org\/docs\/extensions\/spatial>\n","use_cases":["Ingest a GeoJSON file and create a map view with PMTiles and a spatial query panel with GeoParquet.","Convert a Shapefile to EPSG:4326 and push to Cloudflare R2 for offline access."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/datopian\/portaljs\/blob\/fc7ccd651459549a962c8b7aa08f60f8849fd9a5\/skills\/portaljs-add-geo\/SKILL.md","source_commit":"fc7ccd651459549a962c8b7aa08f60f8849fd9a5","license":"MIT","version":"1.0.0","listing_approved_at":"2026-11-22","created_at":"2026-11-21T15:48:46.000000Z","updated_at":"2026-11-22T11:18:24.000000Z","seo_title":"Add Geo Data to PortalJS","seo_description":"Automate geospatial data ingestion into PortalJS with no server. Create dual-tier datasets for map and query views.","seo_keywords":["portaljs add geo","geospatial data ingestion","vector tile generation","spatial query dataset","map preview portaljs"]}}