Projects this geometry into a new spatial reference.
[Visual Basic 6.0] Sub Project(
ByVal newReferenceSystem As ISpatialReference _
)
[Visual Basic .NET] Public Sub Project ( _ ByVal newReferenceSystem As ISpatialReference _ )
[C#] public void Project ( ISpatialReference newReferenceSystem );
[Java] public void project ( ISpatialReference newReferenceSystem ) throws IOException, AutomationException
[C++] HRESULT Project( ISpatialReference* newReferenceSystem );
To Project, the geometry needs to have a Spatial Reference set, and not have an UnknownCoordinateSystem. The new spatial reference system passed to the method defines the output coordinate system. If either spatial reference is Unknown, the coordinates are not changed. The Z and measure values are not changed by the Project method.
A geometry is not densified before it is projected. This can lead to the output geometries not reflecting the 'true' shape in the new coordinate system. A straight line in one coordinate system is not necessarily a straight line in a different coordinate system. Use IGeometry2::ProjectEx if you want to densify the geometries while they are projected.
The Project method must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometry types.
If a geometry is projected to a projected coordinate system that can't represent the geographic area where the geometry is located (or if trying to move an xy coordinate from outside the projected coordinate system back into geographic), the geometry will be set to empty.
Note: This method can only be called upon the top level geometries (Points, Multipoints, Polylines and Polygons). If the from/to spatial references have different geographic coordinate systems, the Project method looks for a GeoTransformationsOperationSet. If the set of Geotransformations is present in memory, Project will use it to perform a geographic/datum Transformation. To use a specific geotransformation, use the IGeometry2::ProjectEx method.
//Create Spatial Reference Factory
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
ISpatialReference sr1;
//GCS to project from
IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983);
sr1 = gcs;
sr1.SetFalseOriginAndUnits(-180, -90, 1000000);
//Projected Coordinate System to project into
IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert);
pcs.SetFalseOriginAndUnits(0, 0, 1000);
ISpatialReference sr2;
sr2 = pcs;
//Point to project
IPoint point = new PointClass() as IPoint;
point.PutCoords(-117.17, 34.06);
//Geometry Interface to do actual project
IGeometry geometry;
geometry = point;
geometry.SpatialReference = sr1;
geometry.Project(sr2);
point = geometry as IPoint;
double x;
double y;
point.QueryCoords(out x, out y);
Debug.Print("X: " + x.ToString());
Debug.Print("Y: " + y.ToString());
A VB example that projects from a Geographic Coordinate System (esriSRGeoCS_NAD1983) to a Projected Coordinate System (esriSRProjCS_NAD1983N_AmericaLambert).
Dim pSpRef1 As ISpatialReference
Dim pSpRFc As SpatialReferenceEnvironment
Set pSpRFc = New SpatialReferenceEnvironment
Dim pGCS As IGeographicCoordinateSystem
Set pGCS = pSpRFc.CreateGeographicCoordinateSystem(esriSRGeoCS_NAD1983)
Set pSpRef1 = pGCS
pSpRef1.SetFalseOriginAndUnits -180, -90, 1000000
Dim pPCS As IProjectedCoordinateSystem
Dim pSpRef2 As ISpatialReference
Set pPCS = pSpRFc.CreateProjectedCoordinateSystem(esriSRProjCS_NAD1983N_AmericaLambert)
pPCS.SetFalseOriginAndUnits 0, 0, 1000
Set pSpRef2 = pPCS
Dim pPoint As IPoint
Set pPoint = New point
pPoint.PutCoords -117.17, 34.06
Dim pGeo As IGeometry
Set pGeo = pPoint
Set pGeo.SpatialReference = pSpRef1
pGeo.Project pSpRef2