import { worldToImage } from "@arcgis/core/layers/orientedImagery/transformations/worldToImage.js";const { worldToImage } = await $arcgis.import("@arcgis/core/layers/orientedImagery/transformations/worldToImage.js");- Since
- ArcGIS Maps SDK for JavaScript 4.31
Provides the utility function to convert geographic coordinates to image coordinates. This function is currently utilized in the Oriented Imagery widget to extract image coordinates for the map-image location tool and for constructing the current footprint generated for the images displayed in the oriented imagery widget.
Functions
| Name | Return Type | Object |
|---|---|---|
| |
worldToImage
Transforms a point or an array of points from geographic world coordinates to image space coordinates. The function supports both single points and collections of points.
- Signature
-
worldToImage (pointOrPoints: Point | ReadonlyArrayOrCollection<Point>, properties: WorldToImageProperties): LocationInImageSpace | LocationInImageSpace[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| pointOrPoints | A single | | |
| properties | An object containing the properties required for the transformation, such as camera location (selected feature), affineTransformations, rotation matrix, focalLength, imageHeight, imageWidth, horizontalFieldOfView and verticalFieldOfView. | |
- Returns
- LocationInImageSpace | LocationInImageSpace[]
A
LocationInImageSpacewhich is an object withxandyproperties representing the image coordinates (in rows and columns), where (0, 0) corresponds to the center of the upper left pixel. This function returns aLocationInImageSpaceobject if a single point is provided, or an array ofLocationInImageSpaceobjects if a collection of points is provided.
Example
const point = new Point({ x: -13045967.713, y: 4036342.97, z: 0, spatialReference: SpatialReference.WebMercator,});
const properties = { affineTransformations: [2015.5, 1, 0, 1511.5, 0, -1], cameraLocation: new Point({ x: -13045995.27, y: 4036379.178, z: 1.549999952, spatialReference: SpatialReference.WebMercator, }), horizontalFieldOfView: 65.47045135, imageHeight: 3024, imageWidth: 4032, rotationMatrix: [ -0.6710996455056446, 4.539564596921633e-17, -0.7413671599161904, -0.7413671599161904, -4.1093001638870556e-17, 0.6710996455056446, 0, 1, 6.123233995736766e-17 ], verticalFieldOfView: 46.39718246,};
const imageLocation = worldToImage(point, properties);
console.log(imageLocation);