arcgis-spatial-analysis
Skill1 starsChanged 6 months agoMITView on GitHub
Run server-side spatial analysis with the ArcGIS Maps SDK for JavaScript 5.1: geoprocessing services via the geoprocessor module (execute for synchronous tasks, submitJob for asynchronous ones), typed GP inputs (FeatureSet, LinearUnit), failed jobs (waitForJobCompletion rejects with the JobInfo), and summary statistics with outStatistics instead of downloading capped features. Use this skill whenever the user runs a GP tool, a viewshed/hotspot/enrichment task, or computes aggregate statistics over features.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- GeoDaoyu/arcgis-maps-sdk-js-ai-contexttheir own version, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- GeoDaoyu/arcgis-maps-sdk-js-ai-context★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository73 other files it gives its agents.
- skills/arcgis-3d-layers/AGENTS.mdAGENTS.md
- skills/arcgis-advanced-layers/AGENTS.mdAGENTS.md
- skills/arcgis-ai-components/AGENTS.mdAGENTS.md
- skills/arcgis-arcade/AGENTS.mdAGENTS.md
- skills/arcgis-authentication/AGENTS.mdAGENTS.md
- skills/arcgis-charts/AGENTS.mdAGENTS.md
- skills/arcgis-cim-symbols/AGENTS.mdAGENTS.md
- skills/arcgis-coding-components/AGENTS.mdAGENTS.md
- skills/arcgis-coordinates-projection/AGENTS.mdAGENTS.md
- skills/arcgis-core-maps/AGENTS.mdAGENTS.md
- skills/arcgis-core-utilities/AGENTS.mdAGENTS.md
- skills/arcgis-custom-rendering/AGENTS.mdAGENTS.md
- skills/arcgis-editing/AGENTS.mdAGENTS.md
- skills/arcgis-embeddable-maps/AGENTS.mdAGENTS.md
- skills/arcgis-feature-effects/AGENTS.mdAGENTS.md
- skills/arcgis-geometry-operations/AGENTS.mdAGENTS.md
- skills/arcgis-imagery/AGENTS.mdAGENTS.md
- skills/arcgis-interaction/AGENTS.mdAGENTS.md
- skills/arcgis-knowledge-graphs/AGENTS.mdAGENTS.md
- skills/arcgis-layers/AGENTS.mdAGENTS.md
- skills/arcgis-map-tools/AGENTS.mdAGENTS.md
- skills/arcgis-parquet/AGENTS.mdAGENTS.md
- skills/arcgis-performance/AGENTS.mdAGENTS.md
- skills/arcgis-popup-templates/AGENTS.mdAGENTS.md
- skills/arcgis-portal-content/AGENTS.mdAGENTS.md
- skills/arcgis-rest-services/AGENTS.mdAGENTS.md
- skills/arcgis-scene-environment/AGENTS.mdAGENTS.md
- skills/arcgis-smart-mapping/AGENTS.mdAGENTS.md
- skills/arcgis-spatial-analysis/AGENTS.mdAGENTS.md
- skills/arcgis-starter-app/AGENTS.mdAGENTS.md
- skills/arcgis-tables-forms/AGENTS.mdAGENTS.md
- skills/arcgis-time-animation/AGENTS.mdAGENTS.md
- skills/arcgis-utility-networks/AGENTS.mdAGENTS.md
- skills/arcgis-visualization/AGENTS.mdAGENTS.md
- skills/arcgis-widgets-advanced/AGENTS.mdAGENTS.md
- skills/arcgis-widgets-ui/AGENTS.mdAGENTS.md
- skills/hello-world/AGENTS.mdAGENTS.md
- arcgis-3d-layersSkill
- arcgis-advanced-layersSkill
- arcgis-ai-componentsSkill
- arcgis-arcadeSkill
- arcgis-authenticationSkill
- arcgis-chartsSkill
- arcgis-cim-symbolsSkill
- arcgis-coding-componentsSkill
- arcgis-coordinates-projectionSkill
- arcgis-core-mapsSkill
- arcgis-core-utilitiesSkill
- arcgis-custom-renderingSkill
- arcgis-editingSkill
- arcgis-embeddable-mapsSkill
- arcgis-feature-effectsSkill
- arcgis-geometry-operationsSkill
- arcgis-imagerySkill
- arcgis-interactionSkill
- arcgis-knowledge-graphsSkill
- arcgis-layersSkill
- arcgis-map-toolsSkill
- arcgis-parquetSkill
- arcgis-performanceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 77
Default: read the task's REST page first (<task url>?f=json): execution type, parameter names and data types.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spatial Analysis
When to use: Activate this skill whenever the user runs a geoprocessing tool/job or computes aggregate statistics over features.
Overview
Heavy analysis runs on a server via geoprocessing; aggregation runs as statistics queries.
- Problem it solves: analysis too heavy or proprietary for client-side geometry.
- Who it serves: developers running GP models, enrichment, and statistics.
- Pattern it teaches:
executefor synchronous tasks,submitJobfor asynchronous ones, typed inputs. - What it does NOT cover: client geometry (see
arcgis-geometry-operations) or routing (seearcgis-rest-services).
Quick Start
import * as geoprocessor from "@arcgis/core/rest/geoprocessor.js";
import FeatureSet from "@arcgis/core/rest/support/FeatureSet.js";
import LinearUnit from "@arcgis/core/rest/support/LinearUnit.js";
import Graphic from "@arcgis/core/Graphic.js";
import Point from "@arcgis/core/geometry/Point.js";
const VIEWSHED = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed";
const observer = new FeatureSet({ features: [new Graphic({ geometry: new Point({ longitude: -122.42, latitude: 37.77 }) })] });
const { results } = (await geoprocessor.execute(VIEWSHED, {
Input_Observation_Point: observer, // GPFeatureRecordSetLayer → FeatureSet
Viewshed_Distance: new LinearUnit({ distance: 5, units: "kilometers" }), // GPLinearUnit → LinearUnit
})) as { results: Array<{ paramName: string; value: FeatureSet }> };
const viewshed = results.find((p) => p.paramName === "Viewshed_Result")?.value; // 73 polygons, measuredDecision Tree
- What does the task page say under "Execution Type"?
esriExecutionTypeSynchronous→geoprocessor.execute(url, params).esriExecutionTypeAsynchronous→geoprocessor.submitJob(url, params)+waitForJobCompletion()+fetchResultData(name).
- Each input's
dataTypeon the same page?GPFeatureRecordSetLayer→FeatureSet;GPLinearUnit→LinearUnit;GPString/GPDouble→ plain values.
- Just aggregates over features?
- Yes → a statistics query (
outStatistics), not a GP task and not a client-side loop.
- Yes → a statistics query (
Default: read the task's REST page first (<task url>?f=json): execution type, parameter names and data types.
Import Patterns
Direct ESM (recommended for npm/Vite/Webpack)
import * as geoprocessor from "@arcgis/core/rest/geoprocessor.js";Dynamic Imports (CDN)
const geoprocessor = await $arcgis.import("@arcgis/core/rest/geoprocessor.js");Map Components (recommended for new projects)
// Feed inputs from the component view (sketch/query); render outputs as layers or graphics.
import "@arcgis/map-components/components/arcgis-map";Key Concepts
Concept 1: execute vs submitJob
The service decides. Measured with 5.1.27: execute on an asynchronous task failed with
Error performing execute operation. An asynchronous job went job-executing → job-succeeded, and
fetchResultData("Hotspot_Raster") returned a raster-data-layer parameter.
Concept 2: Parameters are typed by the service
Inputs are keyed by the task's parameter names and must match its dataType. Measured: the server matched names
case-insensitively (input_observation_point worked), but a misspelled name, a bare number for a GPLinearUnit or
a single Graphic for a GPFeatureRecordSetLayer all failed with the same Unable to complete operation., which
names neither the parameter nor the problem. A FeatureSet and its toJSON() both worked.
Concept 3: Results
execute resolves to { results, messages }; each result is a parameter value with paramName, dataType and
value (a real FeatureSet for feature outputs, measured). Find outputs by paramName, not by index.
Common Pitfalls (Top 3)
Pitfall 1: Aggregating features on the client
// ❌ Anti-pattern
const { features } = await layer.queryFeatures({ where: "1=1", outFields: ["POP"] });
const total = features.reduce((s, f) => s + f.attributes.POP, 0);// ✅ Correct
const q = layer.createQuery();
q.outStatistics = [{ statisticType: "sum", onStatisticField: "POP", outStatisticFieldName: "total" }];
const total = (await layer.queryFeatures(q)).features[0].attributes.total;Impact: measured on US cities: the client loop summed 54,124,707 from the first 1000 rows
(exceededTransferLimit: true); the statistics query returned the real 165,628,942. It is a wrong number, not
just a slow one.
Pitfall 2: Plain values for typed GP inputs
// ❌ Anti-pattern
geoprocessor.execute(VIEWSHED, { Input_Observation_Point: graphic, Viewshed_Distance: 5000 });// ✅ Correct
geoprocessor.execute(VIEWSHED, {
Input_Observation_Point: new FeatureSet({ features: [graphic] }),
Viewshed_Distance: new LinearUnit({ distance: 5, units: "kilometers" }),
});Impact: measured: each of those two plain values made the task fail with Unable to complete operation.. Check
each parameter's dataType on the task page.
Pitfall 3: Treating a failed job as a resolved one
// ❌ Anti-pattern
const done = await job.waitForJobCompletion();
if (done.jobStatus !== "job-succeeded") showError(done.jobStatus); // never runs on failure// ✅ Correct
try {
await job.waitForJobCompletion();
} catch (failed) {
const info = failed as JobInfo; // it rejects with the JobInfo, not an Error
showError(info.jobStatus, info.messages.at(-1)?.description);
}Impact: measured: a job with an invalid input rejected with a JobInfo (jobStatus job-failed, last message
Failed.). e.message is undefined, so a generic error handler shows nothing useful.
When to Read references/
| If you need... | Read |
| geoprocessor / statistics signatures | references/api-detail.md |
| GP + statistics examples | references/examples.md |
| More pitfalls (5+ extended) | references/pitfalls.md |
Related Skills
arcgis-rest-services— other REST tasks (route, locator)arcgis-geometry-operations— client-side geometryarcgis-layers— the layers you analyze
Reference Samples
Changelog
- 0.2.0 (2026-10-27): SDK 5.1. Measured against public GP services in
tests/runtime/casos/arcgis-spatial-analysis.ts. The old example and snippet passedViewshed_Distance: 5000, which fails (GPLinearUnitneeds aLinearUnit). The old failed-job pitfall checkedjobStatusafterwaitForJobCompletion(), but a failed job rejects with the JobInfo. The client-side sum is not just slow but wrong (54 M of 165 M, capped at 1000 rows). Parameter names were not case-sensitive on the server; their spelling and type are what fail, with an opaque message. Replaced the comment-only auth pitfall. - 0.1.0 (2026-05-31): Initial release.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

