worldToImage

AMD: require(["esri/layers/orientedImagery/transformations/worldToImage"], (worldToImage) => { /* code goes here */ });
ESM: import * as worldToImage from "@arcgis/core/layers/orientedImagery/transformations/worldToImage.js";
Object: esri/layers/orientedImagery/transformations/worldToImage
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

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.

Method Overview

Name Return Type Summary Object

Transforms a point or an array of points from geographic world coordinates to image space coordinates.

worldToImage

Method Details

worldToImage

Method
worldToImage(pointOrPoints, properties){PixelLocation |PixelLocation[]}

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.

Parameters
pointOrPoints Point|Point[]|Collection<Point>

A single Point or an array or collection of points representing the geographic coordinates to be transformed.

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
Type Description
PixelLocation | PixelLocation[] A LocationInImageSpace which is an object with x and y properties representing the image coordinates (in rows and columns), where (0, 0) corresponds to the center of the upper left pixel. This function returns a LocationInImageSpace object if a single point is provided, or an array of LocationInImageSpace objects 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);

Type Definitions

PixelLocation

Type Definition
PixelLocation

Represents the pixel location in image space, where (0, 0) corresponds to the center of the upper left pixel.

Properties
x Number

The row the pixel location.

y Number

The column the pixel location.

WorldToImageProperties

Type Definition
WorldToImageProperties

Represents the properties required for transforming world coordinates to image coordinates. For more information on the properties, please refer to the Oriented Imagery table.

Properties
affineTransformations Number[]

A fixed length array of 6 numbers corresponding to the camera affine values A0, A1, A2, B0, B1, B2. The coefficient of the affine transformation establishes a relationship between the sensor space and image space. The direction is from ground to image. A0, A1, and A2 represent the translation in x direction, while B0, B1, and B2 represent the translation in y direction. Please refer to the Oriented Imagery table for more information on the afffine values.

cameraLocation Point

A Point representing the camera location in world coordinates where the image was captured.

focalLength Number

The focal length of the camera lens. The unit can be microns, millimeters, or pixels. This parameter is used if ImageWidth and ImageHeight are not provided.

principalOffsetPoint Number[]
optional

A fixed length array of 2 numbers specifying the x-coordinate and y-coordinate of the principal point of the autocollimation. The units must be the same as the unit used for FocalLength. The default value is [0,0]. This is an optional parameter.

radialDistortionCoefficients Number[]
optional

The radial distortion is specified as an array of three numbers, indicating [K1,K2,K3] coefficient values. The coupling unit is the same as the unit specified for FocalLength. The default value is [0,0,0]. This is an optional parameter.

rotationMatrix Number[]

The row-wise sorted rotation matrix that defines the transformation from image space to map space, specified as an array of nine floating-point values.

tangentialDistortionCoefficients Number[]
optional

The tangential distortion is specified as an array of three numbers, indicating [P1,P2] coefficient values. The coupling unit is the same as the unit used for FocalLength. The default value is [0,0]. This is an optional parameter.

horizontalFieldOfView Number

The camera’s field-of-view in a horizontal direction. The unit is degrees. The valid values range from 0 through 360.

verticalFieldOfView Number

The camera’s field-of-view in the vertical direction. The unit is degrees. The valid values range from 0 through 180.

imageHeight Number

Height of the image used for world to image transformation, in pixels. This parameter is used if the focal length is not provided.

imageWidth Number

image used for world to image transformation, in pixels. This parameter is used if the focal length is not provided.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.