Geometry service Project method
The Project method transforms an array of geometries from their current spatial reference to a destination spatial reference.
Project(SpatialReference InSpatialReference, SpatialReference OutSpatialReference, boolean TransformForward, GeoTransformation Transformation, Envelope Extent, Geometry[] InGeometryArray)
Parameter |
Description |
---|---|
InSpatialReference |
The SpatialReference of the geometries in InGeometryArray. The current spatial reference. Cannot be null. |
OutSpatialReference |
The SpatialReference of the geometry returned from the project operation. The destination spatial reference. Cannot be null. |
TransformForward |
(optional) A boolean indicating whether to transform forward (true) or not (false). |
Transformation |
(optional) An instance of a GeoTransformation must also specify forward or reverse. For a list of valid WKID codes for transformations, see the discussion Finding a Well-Known ID. |
Extent |
(optional) An extent Envelope which will optimize the projection operation by checking if the Envelope is completely contained in the horizon. |
InGeometryArray |
The array of geometries to be projected. All geometries are assumed to be in the coordinate system defined by InSpatialReference. |
Return Value
An array of Geometry (Geometry[]).
Remarks
The Project method applies the projection OutSpatialReference to a copy of each element of InGeometryArray and places the result in an output Geometry array. All inputs are assumed to be in the spatial reference InSpatialReference which cannot be null. The input geometries are not modified. The input array can contain mixed top-level geometry types (specifically points, multipoints, polylines, and polygons). The input array can also contain envelopes. If Extent is specified, then all input geometries are then assumed to be contained in it.
The SpatialReference property for all returned geometry will be null. It is the consumer's responsibility to assign the spatial reference to each geometry returned, if desired. In this case, the spatial reference is assumed to be the output spatial reference defined for the Project operation.
If Transformation is not specified, a search is made through a set of default GeoTransformations. Currently, the following transformations are in that set:
- esriSRGeoTransformation_NAD_1927_TO_NAD_1983_NADCON, forward and reverse, WKID=1241
- esriSRGeoTransformation_NAD1983_To_WGS1984_1, forward and reverse, WKID=1188
- esriSRGeoTransformation_NAD1927_To_WGS1984_4, forward and reverse, WKID=1173
For a complete list of EPSG or ESRI WKIDs for spatial references and transformations, see the discussion Finding a Well-Known ID.
Examples
C#
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKID = 4326;
inputSpatialReference.WKIDSpecified = true;
SpatialReference outputSpatialReference = new ProjectedCoordinateSystem();
// USA_Contiguous_Lambert_Conformal_Conic
outputSpatialReference.WKID = 102004;
outputSpatialReference.WKIDSpecified = true;
PointN pnt1 = new PointN();
pnt1.X = -120;
pnt1.Y = 50;
PointN pnt2 = new PointN();
pnt2.X = -110;
pnt2.Y = 40;
PointN pnt3 = new PointN();
pnt3.X = -130;
pnt3.Y = 40;
PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3 };
Path path1 = new Path();
path1.PointArray = pnts1;
Path[] paths = new Path[] { path1 };
PolylineN polylinen = new PolylineN();
polylinen.PathArray = paths;
Ring ring1 = new Ring();
ring1.PointArray = pnts1;
Ring[] rings = new Ring[] { ring1 };
PolygonN polygonn = new PolygonN();
polygonn.RingArray = rings;
Geometry[] inputGeometry = new Geometry[] { pnt1, polylinen, polygonn };
bool transformForward = false;
GeoTransformation transformation = new GeoTransformation();
// NAD1983_To_WGS1984_1
transformation.WKID = 1188;
transformation.WKIDSpecified = true;
EnvelopeN extent = null;
Geometry[] outputGeometry = geometryService.Project(inputSpatialReference, outputSpatialReference, transformForward,transformation, extent, inputGeometry);
VB.NET
Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()
geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"
Dim inputSpatialReference As SpatialReference = New GeographicCoordinateSystem()
inputSpatialReference.WKID = 4326
inputSpatialReference.WKIDSpecified = True
Dim outputSpatialReference As SpatialReference = New ProjectedCoordinateSystem()
' USA_Contiguous_Lambert_Conformal_Conic
outputSpatialReference.WKID = 102004
outputSpatialReference.WKIDSpecified = True
Dim pnt1 As PointN = New PointN()
pnt1.X = -120
pnt1.Y = 50
Dim pnt2 As PointN = New PointN()
pnt2.X = -110
pnt2.Y = 40
Dim pnt3 As PointN = New PointN()
pnt3.X = -130
pnt3.Y = 40
Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3}
Dim path1 As Path = New Path()
path1.PointArray = pnts1
Dim paths() As Path = New Path() {path1}
Dim polylinen As PolylineN = New PolylineN()
polylinen.PathArray = paths
Dim ring1 As Ring = New Ring()
ring1.PointArray = pnts1
Dim rings() As Ring = New Ring() {ring1}
Dim polygonn As PolygonN = New PolygonN()
polygonn.RingArray = rings
Dim inputGeomeTry() As Geometry = New Geometry() {pnt1, polylinen, polygonn}
Dim transformForward As Boolean = False
Dim transformation As GeoTransformation = New GeoTransformation()
' NAD1983_To_WGS1984_1
transformation.WKID = 1188
transformation.WKIDSpecified = True
Dim extent As EnvelopeN = Nothing
Dim outputGeomeTry as GeomeTry() = geomeTryService.Project(inputSpatialReference, outputSpatialReference,transformForward,transformation, extent, inputGeomeTry)