Arcengine settings Coordinate System

Source: Internet
Author: User

ArcGIS Engine provides a series of objects for developers to manage Coordinate Systems of GIS systems.
For most developers, understanding ProjectedCoordinateSysteM, GeographicCoordinateSystEm,
SpatialReference Environment is necessary for the three component classes,
For advanced developers, you may need to use a custom coordinate system.
These objects include Projection, Datum, AngularUnit, Spheriod, PrimeMeridian, and
GeoTransformation.
1. ISpatialReference geographical coordinate system object
(The setting of spatial reference mainly refers to the geographic coordinate system object. After setting it, assign it to the desired object)
// Create a geographic coordinate system object
ISpatialReferenceFactorySpatialReferenceFactory = new SpatialReferenceEnvironmEntClass ();
ISpatialReference spatialReference = spatialReferenceFactory. CreateGeographicCoordinaTeSystem (int) esriSRGeoCSType. esriSRGeoCS_WGS1984 );

2. Spatial Change reference
The AlterSpatialReference method of the IGeoDatasetSchemaEdit interface can be used to change the spatial reference.Attribute to see if it can be changed
PGeoDatasetSchemaEdit. AlterSpatialReference (pSpatialReference );

Instance:
/// <Summary>
/// Reference for changing the space of a Layer
/// </Summary>
/// <Param name = "pFeatureLayer"> layer </param>
/// <Param name = "pGeoType"> spatial reference type </param>
Private void ChangeLayerRef (IFeatureLayer pFeatureLayer, int gcsType)
{
Try
{
IFeatureClass pFeatureClass = pFeatureLayer. FeatureClass;
// QI to IGeoDataset
IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
// QI to IGeoDatasetSchemaEdit
IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit;
If (pGeoDatasetSchemaEdit. CanAlterSpatialReference= True)
{
// Create SpatialReferenceEnvironmEntClass object
ISpatialReferenceFactory2 pspareffacloud = new SpatialReferenceEnvironmEntClass ();
// Create a geographic coordinate system object
IGeographicCoordinateSysTem pNewGeoSys = pspareffacloud. CreateGeographicCoordinaTeSystem (gcsType); // 4214 stands for Beijing1954
PGeoDatasetSchemaEdit. AlterSpatialReference (pNewGeoSys );
}
}
Catch (Exception Err)
{
MessageBox. Show (Err. Message, "prompt", MessageBoxButtons. OK, MessageBoxIcon. Information );
}
}

3. Spatial coordinate Enumeration
EsriSRGeoCSType
EsriSRProjCSType

4. Custom Coordinate System

Use ArcMap to define the coordinate system and export it to a prj file. Use ISpatialReferenceFactory. createesrispatialreferencefromp1_file to create a coordinate system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.