@saschabrunnerch/arcgis-maps-sdk-js-ai-context 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +163 -201
  2. package/bin/cli.js +157 -173
  3. package/contexts/4.34/{claude → skills}/arcgis-3d-advanced/SKILL.md +586 -586
  4. package/contexts/4.34/{claude → skills}/arcgis-advanced-layers/SKILL.md +431 -431
  5. package/contexts/4.34/{claude → skills}/arcgis-analysis-services/SKILL.md +607 -607
  6. package/contexts/4.34/{claude → skills}/arcgis-authentication/SKILL.md +301 -301
  7. package/contexts/4.34/{claude → skills}/arcgis-cim-symbols/SKILL.md +486 -486
  8. package/contexts/4.34/{claude → skills}/arcgis-coordinates-projection/SKILL.md +406 -406
  9. package/contexts/4.34/{claude → skills}/arcgis-core-maps/SKILL.md +739 -739
  10. package/contexts/4.34/{claude → skills}/arcgis-core-utilities/SKILL.md +732 -732
  11. package/contexts/4.34/{claude → skills}/arcgis-custom-rendering/SKILL.md +445 -445
  12. package/contexts/4.34/{claude → skills}/arcgis-editing-advanced/SKILL.md +702 -702
  13. package/contexts/4.34/{claude → skills}/arcgis-feature-effects/SKILL.md +393 -393
  14. package/contexts/4.34/{claude → skills}/arcgis-geometry-operations/SKILL.md +489 -489
  15. package/contexts/4.34/{claude → skills}/arcgis-imagery/SKILL.md +307 -307
  16. package/contexts/4.34/{claude → skills}/arcgis-interaction/SKILL.md +572 -572
  17. package/contexts/4.34/{claude → skills}/arcgis-knowledge-graphs/SKILL.md +582 -582
  18. package/contexts/4.34/{claude → skills}/arcgis-layers/SKILL.md +601 -601
  19. package/contexts/4.34/{claude → skills}/arcgis-map-tools/SKILL.md +668 -668
  20. package/contexts/4.34/{claude → skills}/arcgis-media-layers/SKILL.md +290 -290
  21. package/contexts/4.34/{claude → skills}/arcgis-portal-content/SKILL.md +679 -679
  22. package/contexts/4.34/{claude → skills}/arcgis-scene-effects/SKILL.md +512 -512
  23. package/contexts/4.34/{claude → skills}/arcgis-smart-mapping/SKILL.md +686 -686
  24. package/contexts/4.34/skills/arcgis-starter-app/SKILL.md +273 -0
  25. package/contexts/4.34/skills/arcgis-starter-app-extended/SKILL.md +649 -0
  26. package/contexts/4.34/{claude → skills}/arcgis-tables-forms/SKILL.md +877 -877
  27. package/contexts/4.34/{claude → skills}/arcgis-time-animation/SKILL.md +722 -722
  28. package/contexts/4.34/{claude → skills}/arcgis-utility-networks/SKILL.md +301 -301
  29. package/contexts/4.34/{claude → skills}/arcgis-visualization/SKILL.md +580 -580
  30. package/contexts/4.34/{claude → skills}/arcgis-widgets-ui/SKILL.md +574 -574
  31. package/lib/installer.js +294 -379
  32. package/package.json +45 -45
  33. package/contexts/4.34/copilot/arcgis-3d.instructions.md +0 -267
  34. package/contexts/4.34/copilot/arcgis-analysis.instructions.md +0 -294
  35. package/contexts/4.34/copilot/arcgis-arcade.instructions.md +0 -234
  36. package/contexts/4.34/copilot/arcgis-authentication.instructions.md +0 -187
  37. package/contexts/4.34/copilot/arcgis-cim-symbols.instructions.md +0 -177
  38. package/contexts/4.34/copilot/arcgis-core-maps.instructions.md +0 -246
  39. package/contexts/4.34/copilot/arcgis-core-utilities.instructions.md +0 -247
  40. package/contexts/4.34/copilot/arcgis-editing.instructions.md +0 -262
  41. package/contexts/4.34/copilot/arcgis-geometry.instructions.md +0 -225
  42. package/contexts/4.34/copilot/arcgis-layers.instructions.md +0 -278
  43. package/contexts/4.34/copilot/arcgis-popup-templates.instructions.md +0 -266
  44. package/contexts/4.34/copilot/arcgis-portal-advanced.instructions.md +0 -275
  45. package/contexts/4.34/copilot/arcgis-smart-mapping.instructions.md +0 -184
  46. package/contexts/4.34/copilot/arcgis-time-animation.instructions.md +0 -112
  47. package/contexts/4.34/copilot/arcgis-visualization.instructions.md +0 -321
  48. package/contexts/4.34/copilot/arcgis-widgets-ui.instructions.md +0 -277
  49. /package/contexts/4.34/{claude → skills}/arcgis-arcade/SKILL.md +0 -0
  50. /package/contexts/4.34/{claude → skills}/arcgis-popup-templates/SKILL.md +0 -0
@@ -1,489 +1,489 @@
1
- ---
2
- name: arcgis-geometry-operations
3
- description: Create, manipulate, and analyze geometries using geometry classes and geometry operators. Use for spatial calculations, geometry creation, buffering, intersections, unions, and mesh operations.
4
- ---
5
-
6
- # ArcGIS Geometry Operations
7
-
8
- Use this skill for creating geometries and performing spatial operations with the modern geometry operators module.
9
-
10
- > **Important:** The `geometryEngine` and `geometryEngineAsync` modules are **deprecated** as of version 4.29. Use the geometry operators module instead. See the [Deprecation Notice](#deprecated-geometryengine) section for migration guidance.
11
-
12
- ## Geometry Classes Overview
13
-
14
- | Class | Use Case |
15
- |-------|----------|
16
- | Point | Single location (x, y, z, m) |
17
- | Polyline | Lines and paths |
18
- | Polygon | Areas with rings |
19
- | Multipoint | Collection of points |
20
- | Extent | Bounding box |
21
- | Circle | Circular geometry |
22
- | Mesh | 3D mesh with vertices and faces |
23
-
24
- ## Creating Geometries
25
-
26
- ### Point
27
- ```javascript
28
- const point = {
29
- type: "point",
30
- longitude: -118.80657,
31
- latitude: 34.02749,
32
- z: 1000, // Optional elevation
33
- m: 0, // Optional measure
34
- spatialReference: { wkid: 4326 }
35
- };
36
-
37
- // Or using x, y coordinates
38
- const point = {
39
- type: "point",
40
- x: -13044706,
41
- y: 4036320,
42
- spatialReference: { wkid: 102100 } // Web Mercator
43
- };
44
- ```
45
-
46
- ### Polyline
47
- ```javascript
48
- const polyline = {
49
- type: "polyline",
50
- paths: [
51
- [[-118.821527, 34.0139576], [-118.814893, 34.0137161]], // First path
52
- [[-118.8148893, 34.0215816], [-118.813120, 34.0215816]] // Second path
53
- ],
54
- spatialReference: { wkid: 4326 }
55
- };
56
-
57
- // Single path
58
- const line = {
59
- type: "polyline",
60
- paths: [
61
- [-118.821527, 34.0139576],
62
- [-118.814893, 34.0137161],
63
- [-118.808878, 34.0102256]
64
- ]
65
- };
66
- ```
67
-
68
- ### Polygon
69
- ```javascript
70
- const polygon = {
71
- type: "polygon",
72
- rings: [
73
- // Outer ring (clockwise)
74
- [[-118.818984, 34.01991], [-118.806796, 34.01991],
75
- [-118.806796, 34.02937], [-118.818984, 34.02937],
76
- [-118.818984, 34.01991]],
77
- // Inner ring/hole (counter-clockwise) - optional
78
- [[-118.815, 34.022], [-118.810, 34.022],
79
- [-118.810, 34.026], [-118.815, 34.026],
80
- [-118.815, 34.022]]
81
- ],
82
- spatialReference: { wkid: 4326 }
83
- };
84
- ```
85
-
86
- ### Extent
87
- ```javascript
88
- const extent = {
89
- type: "extent",
90
- xmin: -118.82,
91
- ymin: 34.01,
92
- xmax: -118.80,
93
- ymax: 34.03,
94
- spatialReference: { wkid: 4326 }
95
- };
96
- ```
97
-
98
- ### Circle
99
- ```javascript
100
- import Circle from "@arcgis/core/geometry/Circle.js";
101
-
102
- const circle = new Circle({
103
- center: [-118.80657, 34.02749],
104
- radius: 1000,
105
- radiusUnit: "meters", // feet, kilometers, miles, nautical-miles, yards
106
- geodesic: true,
107
- spatialReference: { wkid: 4326 }
108
- });
109
- ```
110
-
111
- ### Multipoint
112
- ```javascript
113
- const multipoint = {
114
- type: "multipoint",
115
- points: [
116
- [-118.821527, 34.0139576],
117
- [-118.814893, 34.0137161],
118
- [-118.808878, 34.0102256]
119
- ],
120
- spatialReference: { wkid: 4326 }
121
- };
122
- ```
123
-
124
- ## Geometry Operators (Modern API)
125
-
126
- The geometry operators module is the modern, recommended approach for geometry operations. Each operator is imported individually for better tree-shaking and performance.
127
-
128
- ### Importing Operators
129
-
130
- ```javascript
131
- // Import specific operators as needed
132
- import buffer from "@arcgis/core/geometry/operators/buffer.js";
133
- import union from "@arcgis/core/geometry/operators/union.js";
134
- import intersects from "@arcgis/core/geometry/operators/intersects.js";
135
-
136
- // Or import multiple at once
137
- import buffer from "@arcgis/core/geometry/operators/buffer.js";
138
- import union from "@arcgis/core/geometry/operators/union.js";
139
- import contains from "@arcgis/core/geometry/operators/contains.js";
140
- import difference from "@arcgis/core/geometry/operators/difference.js";
141
- ```
142
-
143
- ### Buffer Operations
144
-
145
- ```javascript
146
- import buffer from "@arcgis/core/geometry/operators/buffer.js";
147
-
148
- // Simple buffer
149
- const buffered = buffer.execute(point, 1000); // 1000 meters
150
-
151
- // Buffer with options
152
- const buffered = buffer.execute(point, {
153
- distance: 500,
154
- unit: "meters" // feet, kilometers, miles, nautical-miles, yards
155
- });
156
-
157
- // Buffer multiple geometries
158
- const buffered = buffer.execute([point1, point2, point3], 1000);
159
-
160
- // Geodesic buffer (for geographic coordinates)
161
- import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
162
- const geoBuffered = geodesicBuffer.execute(point, {
163
- distance: 1000,
164
- unit: "meters"
165
- });
166
- ```
167
-
168
- ### Spatial Relationships
169
-
170
- ```javascript
171
- // Contains - geometry1 completely contains geometry2
172
- import contains from "@arcgis/core/geometry/operators/contains.js";
173
- const result = contains.execute(polygon, point); // returns boolean
174
-
175
- // Within - geometry1 is completely within geometry2
176
- import within from "@arcgis/core/geometry/operators/within.js";
177
- const result = within.execute(point, polygon); // returns boolean
178
-
179
- // Intersects - geometries share any space
180
- import intersects from "@arcgis/core/geometry/operators/intersects.js";
181
- const result = intersects.execute(polygon1, polygon2); // returns boolean
182
-
183
- // Crosses - geometries cross each other
184
- import crosses from "@arcgis/core/geometry/operators/crosses.js";
185
- const result = crosses.execute(line, polygon); // returns boolean
186
-
187
- // Overlaps - geometries share some but not all space
188
- import overlaps from "@arcgis/core/geometry/operators/overlaps.js";
189
- const result = overlaps.execute(polygon1, polygon2); // returns boolean
190
-
191
- // Touches - geometries share boundary but not interior
192
- import touches from "@arcgis/core/geometry/operators/touches.js";
193
- const result = touches.execute(polygon1, polygon2); // returns boolean
194
-
195
- // Disjoint - geometries don't share any space
196
- import disjoint from "@arcgis/core/geometry/operators/disjoint.js";
197
- const result = disjoint.execute(polygon1, polygon2); // returns boolean
198
-
199
- // Equals - geometries are identical
200
- import equals from "@arcgis/core/geometry/operators/equals.js";
201
- const result = equals.execute(geom1, geom2); // returns boolean
202
- ```
203
-
204
- ### Set Operations
205
-
206
- ```javascript
207
- // Union - combine geometries
208
- import union from "@arcgis/core/geometry/operators/union.js";
209
- const combined = union.execute([polygon1, polygon2, polygon3]);
210
-
211
- // Intersection - common area between geometries
212
- import intersection from "@arcgis/core/geometry/operators/intersection.js";
213
- const common = intersection.execute(polygon1, polygon2);
214
-
215
- // Difference - subtract geometry2 from geometry1
216
- import difference from "@arcgis/core/geometry/operators/difference.js";
217
- const diff = difference.execute(polygon1, polygon2);
218
-
219
- // Symmetric Difference - areas in either but not both
220
- import symmetricDifference from "@arcgis/core/geometry/operators/symmetricDifference.js";
221
- const symDiff = symmetricDifference.execute(polygon1, polygon2);
222
-
223
- // Clip - clip geometry by envelope
224
- import clip from "@arcgis/core/geometry/operators/clip.js";
225
- const clipped = clip.execute(polygon, extent);
226
- ```
227
-
228
- ### Measurements
229
-
230
- ```javascript
231
- // Area (for polygons)
232
- import area from "@arcgis/core/geometry/operators/area.js";
233
- const areaValue = area.execute(polygon); // square meters
234
-
235
- import geodesicArea from "@arcgis/core/geometry/operators/geodesicArea.js";
236
- const geoArea = geodesicArea.execute(polygon, { unit: "square-kilometers" });
237
-
238
- // Length (for polylines)
239
- import length from "@arcgis/core/geometry/operators/length.js";
240
- const lengthValue = length.execute(polyline); // meters
241
-
242
- import geodesicLength from "@arcgis/core/geometry/operators/geodesicLength.js";
243
- const geoLength = geodesicLength.execute(polyline, { unit: "kilometers" });
244
-
245
- // Distance between geometries
246
- import distance from "@arcgis/core/geometry/operators/distance.js";
247
- const dist = distance.execute(point1, point2); // meters
248
- ```
249
-
250
- ### Geometry Manipulation
251
-
252
- ```javascript
253
- // Simplify - remove self-intersections
254
- import simplify from "@arcgis/core/geometry/operators/simplify.js";
255
- const simplified = simplify.execute(polygon);
256
-
257
- // Generalize - reduce vertices
258
- import generalize from "@arcgis/core/geometry/operators/generalize.js";
259
- const generalized = generalize.execute(polyline, {
260
- maxDeviation: 100,
261
- unit: "meters"
262
- });
263
-
264
- // Densify - add vertices
265
- import densify from "@arcgis/core/geometry/operators/densify.js";
266
- const densified = densify.execute(polyline, {
267
- maxSegmentLength: 100,
268
- unit: "meters"
269
- });
270
-
271
- // Offset - create parallel geometry
272
- import offset from "@arcgis/core/geometry/operators/offset.js";
273
- const offsetGeom = offset.execute(polyline, {
274
- distance: 50,
275
- unit: "meters",
276
- joinType: "round" // round, bevel, miter
277
- });
278
-
279
- // Convex Hull
280
- import convexHull from "@arcgis/core/geometry/operators/convexHull.js";
281
- const hull = convexHull.execute(polygon);
282
- const multiHull = convexHull.execute([point1, point2, point3]);
283
-
284
- // Centroid
285
- import centroid from "@arcgis/core/geometry/operators/centroid.js";
286
- const center = centroid.execute(polygon);
287
-
288
- // Label Point (guaranteed inside polygon)
289
- import labelPoint from "@arcgis/core/geometry/operators/labelPoint.js";
290
- const label = labelPoint.execute(polygon);
291
- ```
292
-
293
- ### Available Operators
294
-
295
- | Category | Operators |
296
- |----------|-----------|
297
- | Relationship | `contains`, `crosses`, `disjoint`, `equals`, `intersects`, `overlaps`, `relate`, `touches`, `within` |
298
- | Set Operations | `clip`, `cut`, `difference`, `intersection`, `symmetricDifference`, `union` |
299
- | Buffer | `buffer`, `geodesicBuffer` |
300
- | Shape | `autoComplete`, `boundary`, `convexHull`, `simplify` |
301
- | Measurement | `area`, `geodesicArea`, `length`, `geodesicLength`, `distance` |
302
- | Transform | `densify`, `generalize`, `offset`, `project`, `rotate` |
303
- | Analysis | `centroid`, `labelPoint`, `nearestCoordinate`, `nearestVertex` |
304
-
305
- ## Projection (projectOperator)
306
-
307
- ```javascript
308
- import projectOperator from "@arcgis/core/geometry/operators/projectOperator.js";
309
-
310
- // Load projection engine (required before projecting)
311
- await projectOperator.load();
312
-
313
- // Project geometry to new spatial reference
314
- const projected = projectOperator.execute(geometry, {
315
- outSpatialReference: { wkid: 4326 }
316
- });
317
-
318
- // Project with geographic transformation
319
- const projectedWithTransform = projectOperator.execute(geometry, {
320
- outSpatialReference: { wkid: 4326 },
321
- geographicTransformation: {
322
- steps: [{ wkid: 108190 }] // NAD_1983_To_WGS_1984_5
323
- }
324
- });
325
-
326
- // Get available transformations
327
- const transformations = projectOperator.getTransformations(
328
- inSpatialReference,
329
- outSpatialReference
330
- );
331
- ```
332
-
333
- > **Note:** The legacy `projection` module is deprecated since 4.32. Use `projectOperator` instead.
334
-
335
- ## Web Mercator Utilities
336
-
337
- ```javascript
338
- import webMercatorUtils from "@arcgis/core/geometry/support/webMercatorUtils.js";
339
-
340
- // Convert to Web Mercator
341
- const webMercatorGeom = webMercatorUtils.geographicToWebMercator(geographicPoint);
342
-
343
- // Convert to Geographic
344
- const geoGeom = webMercatorUtils.webMercatorToGeographic(webMercatorPoint);
345
-
346
- // Check if can project
347
- const canProject = webMercatorUtils.canProject(geom1.spatialReference, geom2.spatialReference);
348
- ```
349
-
350
- ## Mesh (3D Geometry)
351
-
352
- Mesh is used for complex 3D surfaces with vertices and faces.
353
-
354
- ```javascript
355
- import Mesh from "@arcgis/core/geometry/Mesh.js";
356
-
357
- // Create mesh from primitives
358
- const box = Mesh.createBox(location, {
359
- size: { width: 100, height: 100, depth: 50 },
360
- material: { color: "red" }
361
- });
362
-
363
- const sphere = Mesh.createSphere(location, {
364
- size: 50,
365
- densificationFactor: 2,
366
- material: { color: "blue" }
367
- });
368
-
369
- const cylinder = Mesh.createCylinder(location, {
370
- size: { width: 50, height: 100 },
371
- material: { color: "green" }
372
- });
373
-
374
- // Load from glTF/GLB
375
- const mesh = await Mesh.createFromGLTF(location, {
376
- url: "model.glb"
377
- });
378
- ```
379
-
380
- ## JSON Utilities
381
-
382
- ```javascript
383
- import jsonUtils from "@arcgis/core/geometry/support/jsonUtils.js";
384
-
385
- // Create geometry from JSON
386
- const geometry = jsonUtils.fromJSON({
387
- rings: [[[-118.8, 34.0], [-118.7, 34.0], [-118.7, 34.1], [-118.8, 34.1], [-118.8, 34.0]]],
388
- spatialReference: { wkid: 4326 }
389
- });
390
-
391
- // Get JSON from geometry
392
- const json = geometry.toJSON();
393
- ```
394
-
395
- ## Common Patterns
396
-
397
- ### Check if Point is in Polygon
398
- ```javascript
399
- import contains from "@arcgis/core/geometry/operators/contains.js";
400
-
401
- function isPointInPolygon(point, polygon) {
402
- return contains.execute(polygon, point);
403
- }
404
- ```
405
-
406
- ### Create Buffer and Query
407
- ```javascript
408
- import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
409
-
410
- async function queryWithinDistance(point, distance, layer) {
411
- const buffer = geodesicBuffer.execute(point, { distance, unit: "meters" });
412
- const query = layer.createQuery();
413
- query.geometry = buffer;
414
- query.spatialRelationship = "contains";
415
- return await layer.queryFeatures(query);
416
- }
417
- ```
418
-
419
- ### Calculate Total Area
420
- ```javascript
421
- import union from "@arcgis/core/geometry/operators/union.js";
422
- import geodesicArea from "@arcgis/core/geometry/operators/geodesicArea.js";
423
-
424
- function calculateTotalArea(polygons) {
425
- const combined = union.execute(polygons);
426
- return geodesicArea.execute(combined, { unit: "square-kilometers" });
427
- }
428
- ```
429
-
430
- ## Common Pitfalls
431
-
432
- 1. **Spatial Reference Mismatch**: Always ensure geometries are in the same spatial reference before operations
433
- ```javascript
434
- // Project if needed
435
- if (!geom1.spatialReference.equals(geom2.spatialReference)) {
436
- geom2 = projection.project(geom2, geom1.spatialReference);
437
- }
438
- ```
439
-
440
- 2. **Geodesic vs Planar**: Use geodesic operators for geographic coordinates (WGS84)
441
- ```javascript
442
- // Use geodesicBuffer for lat/lon, buffer for projected coordinates
443
- import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
444
- import buffer from "@arcgis/core/geometry/operators/buffer.js";
445
- const bufferOp = geometry.spatialReference.isGeographic ? geodesicBuffer : buffer;
446
- ```
447
-
448
- 3. **Ring Orientation**: Outer rings clockwise, holes counter-clockwise
449
-
450
- 4. **Self-intersecting Polygons**: Use `simplify` before operations on user-drawn polygons
451
-
452
- 5. **Load Projection Engine**: Call `projection.load()` before using `projection.project()`
453
-
454
- ---
455
-
456
- ## Deprecated: geometryEngine
457
-
458
- > **DEPRECATED:** The `geometryEngine` and `geometryEngineAsync` modules are deprecated as of version 4.29. Use the geometry operators module (shown above) instead.
459
-
460
- The following is kept for reference when maintaining legacy code. **Do not use for new development.**
461
-
462
- ### Migration Guide
463
-
464
- | Deprecated (geometryEngine) | Modern (operators) |
465
- |-----------------------------|-------------------|
466
- | `geometryEngine.buffer(geom, dist, unit)` | `buffer.execute(geom, { distance: dist, unit })` |
467
- | `geometryEngine.geodesicBuffer(geom, dist, unit)` | `geodesicBuffer.execute(geom, { distance: dist, unit })` |
468
- | `geometryEngine.union([geoms])` | `union.execute([geoms])` |
469
- | `geometryEngine.intersect(g1, g2)` | `intersection.execute(g1, g2)` |
470
- | `geometryEngine.contains(g1, g2)` | `contains.execute(g1, g2)` |
471
- | `geometryEngine.within(g1, g2)` | `within.execute(g1, g2)` |
472
- | `geometryEngine.distance(g1, g2, unit)` | `distance.execute(g1, g2)` |
473
- | `geometryEngine.planarArea(geom, unit)` | `area.execute(geom)` |
474
- | `geometryEngine.geodesicArea(geom, unit)` | `geodesicArea.execute(geom, { unit })` |
475
- | `geometryEngine.simplify(geom)` | `simplify.execute(geom)` |
476
- | `geometryEngine.convexHull(geom)` | `convexHull.execute(geom)` |
477
-
478
- ### Legacy geometryEngine (Deprecated)
479
-
480
- ```javascript
481
- // DEPRECATED - Do not use for new development
482
- import geometryEngine from "@arcgis/core/geometry/geometryEngine.js";
483
-
484
- // These methods still work but will be removed in a future release
485
- const buffer = geometryEngine.buffer(point, 1000, "meters");
486
- const intersects = geometryEngine.intersects(polygon1, polygon2);
487
- const union = geometryEngine.union([polygon1, polygon2]);
488
- ```
489
-
1
+ ---
2
+ name: arcgis-geometry-operations
3
+ description: Create, manipulate, and analyze geometries using geometry classes and geometry operators. Use for spatial calculations, geometry creation, buffering, intersections, unions, and mesh operations.
4
+ ---
5
+
6
+ # ArcGIS Geometry Operations
7
+
8
+ Use this skill for creating geometries and performing spatial operations with the modern geometry operators module.
9
+
10
+ > **Important:** The `geometryEngine` and `geometryEngineAsync` modules are **deprecated** as of version 4.29. Use the geometry operators module instead. See the [Deprecation Notice](#deprecated-geometryengine) section for migration guidance.
11
+
12
+ ## Geometry Classes Overview
13
+
14
+ | Class | Use Case |
15
+ |-------|----------|
16
+ | Point | Single location (x, y, z, m) |
17
+ | Polyline | Lines and paths |
18
+ | Polygon | Areas with rings |
19
+ | Multipoint | Collection of points |
20
+ | Extent | Bounding box |
21
+ | Circle | Circular geometry |
22
+ | Mesh | 3D mesh with vertices and faces |
23
+
24
+ ## Creating Geometries
25
+
26
+ ### Point
27
+ ```javascript
28
+ const point = {
29
+ type: "point",
30
+ longitude: -118.80657,
31
+ latitude: 34.02749,
32
+ z: 1000, // Optional elevation
33
+ m: 0, // Optional measure
34
+ spatialReference: { wkid: 4326 }
35
+ };
36
+
37
+ // Or using x, y coordinates
38
+ const point = {
39
+ type: "point",
40
+ x: -13044706,
41
+ y: 4036320,
42
+ spatialReference: { wkid: 102100 } // Web Mercator
43
+ };
44
+ ```
45
+
46
+ ### Polyline
47
+ ```javascript
48
+ const polyline = {
49
+ type: "polyline",
50
+ paths: [
51
+ [[-118.821527, 34.0139576], [-118.814893, 34.0137161]], // First path
52
+ [[-118.8148893, 34.0215816], [-118.813120, 34.0215816]] // Second path
53
+ ],
54
+ spatialReference: { wkid: 4326 }
55
+ };
56
+
57
+ // Single path
58
+ const line = {
59
+ type: "polyline",
60
+ paths: [
61
+ [-118.821527, 34.0139576],
62
+ [-118.814893, 34.0137161],
63
+ [-118.808878, 34.0102256]
64
+ ]
65
+ };
66
+ ```
67
+
68
+ ### Polygon
69
+ ```javascript
70
+ const polygon = {
71
+ type: "polygon",
72
+ rings: [
73
+ // Outer ring (clockwise)
74
+ [[-118.818984, 34.01991], [-118.806796, 34.01991],
75
+ [-118.806796, 34.02937], [-118.818984, 34.02937],
76
+ [-118.818984, 34.01991]],
77
+ // Inner ring/hole (counter-clockwise) - optional
78
+ [[-118.815, 34.022], [-118.810, 34.022],
79
+ [-118.810, 34.026], [-118.815, 34.026],
80
+ [-118.815, 34.022]]
81
+ ],
82
+ spatialReference: { wkid: 4326 }
83
+ };
84
+ ```
85
+
86
+ ### Extent
87
+ ```javascript
88
+ const extent = {
89
+ type: "extent",
90
+ xmin: -118.82,
91
+ ymin: 34.01,
92
+ xmax: -118.80,
93
+ ymax: 34.03,
94
+ spatialReference: { wkid: 4326 }
95
+ };
96
+ ```
97
+
98
+ ### Circle
99
+ ```javascript
100
+ import Circle from "@arcgis/core/geometry/Circle.js";
101
+
102
+ const circle = new Circle({
103
+ center: [-118.80657, 34.02749],
104
+ radius: 1000,
105
+ radiusUnit: "meters", // feet, kilometers, miles, nautical-miles, yards
106
+ geodesic: true,
107
+ spatialReference: { wkid: 4326 }
108
+ });
109
+ ```
110
+
111
+ ### Multipoint
112
+ ```javascript
113
+ const multipoint = {
114
+ type: "multipoint",
115
+ points: [
116
+ [-118.821527, 34.0139576],
117
+ [-118.814893, 34.0137161],
118
+ [-118.808878, 34.0102256]
119
+ ],
120
+ spatialReference: { wkid: 4326 }
121
+ };
122
+ ```
123
+
124
+ ## Geometry Operators (Modern API)
125
+
126
+ The geometry operators module is the modern, recommended approach for geometry operations. Each operator is imported individually for better tree-shaking and performance.
127
+
128
+ ### Importing Operators
129
+
130
+ ```javascript
131
+ // Import specific operators as needed
132
+ import buffer from "@arcgis/core/geometry/operators/buffer.js";
133
+ import union from "@arcgis/core/geometry/operators/union.js";
134
+ import intersects from "@arcgis/core/geometry/operators/intersects.js";
135
+
136
+ // Or import multiple at once
137
+ import buffer from "@arcgis/core/geometry/operators/buffer.js";
138
+ import union from "@arcgis/core/geometry/operators/union.js";
139
+ import contains from "@arcgis/core/geometry/operators/contains.js";
140
+ import difference from "@arcgis/core/geometry/operators/difference.js";
141
+ ```
142
+
143
+ ### Buffer Operations
144
+
145
+ ```javascript
146
+ import buffer from "@arcgis/core/geometry/operators/buffer.js";
147
+
148
+ // Simple buffer
149
+ const buffered = buffer.execute(point, 1000); // 1000 meters
150
+
151
+ // Buffer with options
152
+ const buffered = buffer.execute(point, {
153
+ distance: 500,
154
+ unit: "meters" // feet, kilometers, miles, nautical-miles, yards
155
+ });
156
+
157
+ // Buffer multiple geometries
158
+ const buffered = buffer.execute([point1, point2, point3], 1000);
159
+
160
+ // Geodesic buffer (for geographic coordinates)
161
+ import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
162
+ const geoBuffered = geodesicBuffer.execute(point, {
163
+ distance: 1000,
164
+ unit: "meters"
165
+ });
166
+ ```
167
+
168
+ ### Spatial Relationships
169
+
170
+ ```javascript
171
+ // Contains - geometry1 completely contains geometry2
172
+ import contains from "@arcgis/core/geometry/operators/contains.js";
173
+ const result = contains.execute(polygon, point); // returns boolean
174
+
175
+ // Within - geometry1 is completely within geometry2
176
+ import within from "@arcgis/core/geometry/operators/within.js";
177
+ const result = within.execute(point, polygon); // returns boolean
178
+
179
+ // Intersects - geometries share any space
180
+ import intersects from "@arcgis/core/geometry/operators/intersects.js";
181
+ const result = intersects.execute(polygon1, polygon2); // returns boolean
182
+
183
+ // Crosses - geometries cross each other
184
+ import crosses from "@arcgis/core/geometry/operators/crosses.js";
185
+ const result = crosses.execute(line, polygon); // returns boolean
186
+
187
+ // Overlaps - geometries share some but not all space
188
+ import overlaps from "@arcgis/core/geometry/operators/overlaps.js";
189
+ const result = overlaps.execute(polygon1, polygon2); // returns boolean
190
+
191
+ // Touches - geometries share boundary but not interior
192
+ import touches from "@arcgis/core/geometry/operators/touches.js";
193
+ const result = touches.execute(polygon1, polygon2); // returns boolean
194
+
195
+ // Disjoint - geometries don't share any space
196
+ import disjoint from "@arcgis/core/geometry/operators/disjoint.js";
197
+ const result = disjoint.execute(polygon1, polygon2); // returns boolean
198
+
199
+ // Equals - geometries are identical
200
+ import equals from "@arcgis/core/geometry/operators/equals.js";
201
+ const result = equals.execute(geom1, geom2); // returns boolean
202
+ ```
203
+
204
+ ### Set Operations
205
+
206
+ ```javascript
207
+ // Union - combine geometries
208
+ import union from "@arcgis/core/geometry/operators/union.js";
209
+ const combined = union.execute([polygon1, polygon2, polygon3]);
210
+
211
+ // Intersection - common area between geometries
212
+ import intersection from "@arcgis/core/geometry/operators/intersection.js";
213
+ const common = intersection.execute(polygon1, polygon2);
214
+
215
+ // Difference - subtract geometry2 from geometry1
216
+ import difference from "@arcgis/core/geometry/operators/difference.js";
217
+ const diff = difference.execute(polygon1, polygon2);
218
+
219
+ // Symmetric Difference - areas in either but not both
220
+ import symmetricDifference from "@arcgis/core/geometry/operators/symmetricDifference.js";
221
+ const symDiff = symmetricDifference.execute(polygon1, polygon2);
222
+
223
+ // Clip - clip geometry by envelope
224
+ import clip from "@arcgis/core/geometry/operators/clip.js";
225
+ const clipped = clip.execute(polygon, extent);
226
+ ```
227
+
228
+ ### Measurements
229
+
230
+ ```javascript
231
+ // Area (for polygons)
232
+ import area from "@arcgis/core/geometry/operators/area.js";
233
+ const areaValue = area.execute(polygon); // square meters
234
+
235
+ import geodesicArea from "@arcgis/core/geometry/operators/geodesicArea.js";
236
+ const geoArea = geodesicArea.execute(polygon, { unit: "square-kilometers" });
237
+
238
+ // Length (for polylines)
239
+ import length from "@arcgis/core/geometry/operators/length.js";
240
+ const lengthValue = length.execute(polyline); // meters
241
+
242
+ import geodesicLength from "@arcgis/core/geometry/operators/geodesicLength.js";
243
+ const geoLength = geodesicLength.execute(polyline, { unit: "kilometers" });
244
+
245
+ // Distance between geometries
246
+ import distance from "@arcgis/core/geometry/operators/distance.js";
247
+ const dist = distance.execute(point1, point2); // meters
248
+ ```
249
+
250
+ ### Geometry Manipulation
251
+
252
+ ```javascript
253
+ // Simplify - remove self-intersections
254
+ import simplify from "@arcgis/core/geometry/operators/simplify.js";
255
+ const simplified = simplify.execute(polygon);
256
+
257
+ // Generalize - reduce vertices
258
+ import generalize from "@arcgis/core/geometry/operators/generalize.js";
259
+ const generalized = generalize.execute(polyline, {
260
+ maxDeviation: 100,
261
+ unit: "meters"
262
+ });
263
+
264
+ // Densify - add vertices
265
+ import densify from "@arcgis/core/geometry/operators/densify.js";
266
+ const densified = densify.execute(polyline, {
267
+ maxSegmentLength: 100,
268
+ unit: "meters"
269
+ });
270
+
271
+ // Offset - create parallel geometry
272
+ import offset from "@arcgis/core/geometry/operators/offset.js";
273
+ const offsetGeom = offset.execute(polyline, {
274
+ distance: 50,
275
+ unit: "meters",
276
+ joinType: "round" // round, bevel, miter
277
+ });
278
+
279
+ // Convex Hull
280
+ import convexHull from "@arcgis/core/geometry/operators/convexHull.js";
281
+ const hull = convexHull.execute(polygon);
282
+ const multiHull = convexHull.execute([point1, point2, point3]);
283
+
284
+ // Centroid
285
+ import centroid from "@arcgis/core/geometry/operators/centroid.js";
286
+ const center = centroid.execute(polygon);
287
+
288
+ // Label Point (guaranteed inside polygon)
289
+ import labelPoint from "@arcgis/core/geometry/operators/labelPoint.js";
290
+ const label = labelPoint.execute(polygon);
291
+ ```
292
+
293
+ ### Available Operators
294
+
295
+ | Category | Operators |
296
+ |----------|-----------|
297
+ | Relationship | `contains`, `crosses`, `disjoint`, `equals`, `intersects`, `overlaps`, `relate`, `touches`, `within` |
298
+ | Set Operations | `clip`, `cut`, `difference`, `intersection`, `symmetricDifference`, `union` |
299
+ | Buffer | `buffer`, `geodesicBuffer` |
300
+ | Shape | `autoComplete`, `boundary`, `convexHull`, `simplify` |
301
+ | Measurement | `area`, `geodesicArea`, `length`, `geodesicLength`, `distance` |
302
+ | Transform | `densify`, `generalize`, `offset`, `project`, `rotate` |
303
+ | Analysis | `centroid`, `labelPoint`, `nearestCoordinate`, `nearestVertex` |
304
+
305
+ ## Projection (projectOperator)
306
+
307
+ ```javascript
308
+ import projectOperator from "@arcgis/core/geometry/operators/projectOperator.js";
309
+
310
+ // Load projection engine (required before projecting)
311
+ await projectOperator.load();
312
+
313
+ // Project geometry to new spatial reference
314
+ const projected = projectOperator.execute(geometry, {
315
+ outSpatialReference: { wkid: 4326 }
316
+ });
317
+
318
+ // Project with geographic transformation
319
+ const projectedWithTransform = projectOperator.execute(geometry, {
320
+ outSpatialReference: { wkid: 4326 },
321
+ geographicTransformation: {
322
+ steps: [{ wkid: 108190 }] // NAD_1983_To_WGS_1984_5
323
+ }
324
+ });
325
+
326
+ // Get available transformations
327
+ const transformations = projectOperator.getTransformations(
328
+ inSpatialReference,
329
+ outSpatialReference
330
+ );
331
+ ```
332
+
333
+ > **Note:** The legacy `projection` module is deprecated since 4.32. Use `projectOperator` instead.
334
+
335
+ ## Web Mercator Utilities
336
+
337
+ ```javascript
338
+ import webMercatorUtils from "@arcgis/core/geometry/support/webMercatorUtils.js";
339
+
340
+ // Convert to Web Mercator
341
+ const webMercatorGeom = webMercatorUtils.geographicToWebMercator(geographicPoint);
342
+
343
+ // Convert to Geographic
344
+ const geoGeom = webMercatorUtils.webMercatorToGeographic(webMercatorPoint);
345
+
346
+ // Check if can project
347
+ const canProject = webMercatorUtils.canProject(geom1.spatialReference, geom2.spatialReference);
348
+ ```
349
+
350
+ ## Mesh (3D Geometry)
351
+
352
+ Mesh is used for complex 3D surfaces with vertices and faces.
353
+
354
+ ```javascript
355
+ import Mesh from "@arcgis/core/geometry/Mesh.js";
356
+
357
+ // Create mesh from primitives
358
+ const box = Mesh.createBox(location, {
359
+ size: { width: 100, height: 100, depth: 50 },
360
+ material: { color: "red" }
361
+ });
362
+
363
+ const sphere = Mesh.createSphere(location, {
364
+ size: 50,
365
+ densificationFactor: 2,
366
+ material: { color: "blue" }
367
+ });
368
+
369
+ const cylinder = Mesh.createCylinder(location, {
370
+ size: { width: 50, height: 100 },
371
+ material: { color: "green" }
372
+ });
373
+
374
+ // Load from glTF/GLB
375
+ const mesh = await Mesh.createFromGLTF(location, {
376
+ url: "model.glb"
377
+ });
378
+ ```
379
+
380
+ ## JSON Utilities
381
+
382
+ ```javascript
383
+ import jsonUtils from "@arcgis/core/geometry/support/jsonUtils.js";
384
+
385
+ // Create geometry from JSON
386
+ const geometry = jsonUtils.fromJSON({
387
+ rings: [[[-118.8, 34.0], [-118.7, 34.0], [-118.7, 34.1], [-118.8, 34.1], [-118.8, 34.0]]],
388
+ spatialReference: { wkid: 4326 }
389
+ });
390
+
391
+ // Get JSON from geometry
392
+ const json = geometry.toJSON();
393
+ ```
394
+
395
+ ## Common Patterns
396
+
397
+ ### Check if Point is in Polygon
398
+ ```javascript
399
+ import contains from "@arcgis/core/geometry/operators/contains.js";
400
+
401
+ function isPointInPolygon(point, polygon) {
402
+ return contains.execute(polygon, point);
403
+ }
404
+ ```
405
+
406
+ ### Create Buffer and Query
407
+ ```javascript
408
+ import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
409
+
410
+ async function queryWithinDistance(point, distance, layer) {
411
+ const buffer = geodesicBuffer.execute(point, { distance, unit: "meters" });
412
+ const query = layer.createQuery();
413
+ query.geometry = buffer;
414
+ query.spatialRelationship = "contains";
415
+ return await layer.queryFeatures(query);
416
+ }
417
+ ```
418
+
419
+ ### Calculate Total Area
420
+ ```javascript
421
+ import union from "@arcgis/core/geometry/operators/union.js";
422
+ import geodesicArea from "@arcgis/core/geometry/operators/geodesicArea.js";
423
+
424
+ function calculateTotalArea(polygons) {
425
+ const combined = union.execute(polygons);
426
+ return geodesicArea.execute(combined, { unit: "square-kilometers" });
427
+ }
428
+ ```
429
+
430
+ ## Common Pitfalls
431
+
432
+ 1. **Spatial Reference Mismatch**: Always ensure geometries are in the same spatial reference before operations
433
+ ```javascript
434
+ // Project if needed
435
+ if (!geom1.spatialReference.equals(geom2.spatialReference)) {
436
+ geom2 = projection.project(geom2, geom1.spatialReference);
437
+ }
438
+ ```
439
+
440
+ 2. **Geodesic vs Planar**: Use geodesic operators for geographic coordinates (WGS84)
441
+ ```javascript
442
+ // Use geodesicBuffer for lat/lon, buffer for projected coordinates
443
+ import geodesicBuffer from "@arcgis/core/geometry/operators/geodesicBuffer.js";
444
+ import buffer from "@arcgis/core/geometry/operators/buffer.js";
445
+ const bufferOp = geometry.spatialReference.isGeographic ? geodesicBuffer : buffer;
446
+ ```
447
+
448
+ 3. **Ring Orientation**: Outer rings clockwise, holes counter-clockwise
449
+
450
+ 4. **Self-intersecting Polygons**: Use `simplify` before operations on user-drawn polygons
451
+
452
+ 5. **Load Projection Engine**: Call `projection.load()` before using `projection.project()`
453
+
454
+ ---
455
+
456
+ ## Deprecated: geometryEngine
457
+
458
+ > **DEPRECATED:** The `geometryEngine` and `geometryEngineAsync` modules are deprecated as of version 4.29. Use the geometry operators module (shown above) instead.
459
+
460
+ The following is kept for reference when maintaining legacy code. **Do not use for new development.**
461
+
462
+ ### Migration Guide
463
+
464
+ | Deprecated (geometryEngine) | Modern (operators) |
465
+ |-----------------------------|-------------------|
466
+ | `geometryEngine.buffer(geom, dist, unit)` | `buffer.execute(geom, { distance: dist, unit })` |
467
+ | `geometryEngine.geodesicBuffer(geom, dist, unit)` | `geodesicBuffer.execute(geom, { distance: dist, unit })` |
468
+ | `geometryEngine.union([geoms])` | `union.execute([geoms])` |
469
+ | `geometryEngine.intersect(g1, g2)` | `intersection.execute(g1, g2)` |
470
+ | `geometryEngine.contains(g1, g2)` | `contains.execute(g1, g2)` |
471
+ | `geometryEngine.within(g1, g2)` | `within.execute(g1, g2)` |
472
+ | `geometryEngine.distance(g1, g2, unit)` | `distance.execute(g1, g2)` |
473
+ | `geometryEngine.planarArea(geom, unit)` | `area.execute(geom)` |
474
+ | `geometryEngine.geodesicArea(geom, unit)` | `geodesicArea.execute(geom, { unit })` |
475
+ | `geometryEngine.simplify(geom)` | `simplify.execute(geom)` |
476
+ | `geometryEngine.convexHull(geom)` | `convexHull.execute(geom)` |
477
+
478
+ ### Legacy geometryEngine (Deprecated)
479
+
480
+ ```javascript
481
+ // DEPRECATED - Do not use for new development
482
+ import geometryEngine from "@arcgis/core/geometry/geometryEngine.js";
483
+
484
+ // These methods still work but will be removed in a future release
485
+ const buffer = geometryEngine.buffer(point, 1000, "meters");
486
+ const intersects = geometryEngine.intersects(polygon1, polygon2);
487
+ const union = geometryEngine.union([polygon1, polygon2]);
488
+ ```
489
+