import { isLoaded, load, execute, executeMany, supportsCurves } from "@arcgis/core/geometry/operators/projectOperator.js";const { isLoaded, load, execute, executeMany, supportsCurves } = await $arcgis.import("@arcgis/core/geometry/operators/projectOperator.js");- Since
- ArcGIS Maps SDK for JavaScript 4.32
Projects geometries (with or without Z/elevation data) from one SpatialReference to another. You can specify a geographic (datum) transformation for this operation, accept the default transformation if one is needed, or set the area of interest.
Projecting your data between coordinate systems sometimes requires transforming between geographic coordinate systems. Geographic transformations are used to transform coordinates between spatial references that have different geographic coordinate systems, and thus different datums. Using the most suitable transformation ensures the best possible accuracy when converting geometries from one spatial reference to another.
The geographicTransformationUtils module provides methods which return the default geographic transformation for the given projection or a list of suitable geographic transformations.
The operator supports limited Z value conversion when the units of the spatial references are different (for example when projecting from NAD83 to WGS84). Full vertical coordinate projection is not available and the operator will throw an exception if the input and output have different vertical coordinate systems.
Known Limitations
This operator currently only supports equation-based geographic transformations. The result geometry is not guaranteed to be simple. Apply the simplifyOperator to ensure the result is topologically simple. Projecting an Extent may return an Extent with a larger area than the input. Vertical coordinate system projections are not supported.
Notes
Verify that isLoaded() returns true before using this module.
Use load() to load this module's dependencies.
Functions
| Name | Return Type | Object |
|---|---|---|
| | ||
| | ||
| | ||
(GeometryWithoutMeshUnion | null | undefined)[] | | |
| |
isLoaded
Indicates if all dependencies of this module have been loaded.
- Signature
-
isLoaded (): boolean
- Returns
- boolean
Returns
trueif this module's dependencies have been loaded.
load
Loads this module's dependencies. This method must be called first if isLoaded returns false.
- See also
- Signature
-
load (): Promise<void>
execute
Projects a geometry to the specified output spatial reference.
- Signature
-
execute (geometry: GeometryUnion, outSpatialReference: SpatialReference, options?: ProjectOptions): GeometryWithoutMeshUnion | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to project. | | |
| outSpatialReference | The spatial reference to which the input geometry is projected. | | |
| options | Additional options. | |
- Returns
- GeometryWithoutMeshUnion | null | undefined
Returns the projected geometry or null.
Example
if (!projectOperator.isLoaded()) { await projectOperator.load();}
const outSpatialReference = new SpatialReference({ wkid: 53008 //Sphere_Sinusoidal projection});
// Project a geometry to a different spatial referenceconst geometry = projectOperator.execute(polygon, outSpatialReference); executeMany
Projects an array of geometries to the specified output spatial reference.
- Signature
-
executeMany (geometries: GeometryUnion[], outSpatialReference: SpatialReference, options?: ProjectOptions): (GeometryWithoutMeshUnion | null | undefined)[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometries | An array of geometries to project. All the geometries must have the same spatial reference. | | |
| outSpatialReference | The spatial reference to which the input geometry is projected. | | |
| options | Additional options. | |
- Returns
- (GeometryWithoutMeshUnion | null | undefined)[]
Returns the projected geometries or null.