Summary of spatial reference (geographic coordinates) methods in ArcGIS Engine

Source: Internet
Author: User

1. Create a space reference

[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Create a space based on the prj file reference
  3. /// </Summary>
  4. /// <Param name = "strprofile"> space reference file </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference createspatialreference (string strprofile)
  7. {
  8. Ispatialreferencefactory pspatialreferencefactory = new spatialreferenceenvironmentclass ();
  9. Ispatialreference pspatialreference = pspatialreferencefactory. createesrispatialreferencefromp1_file (strprofile );
  10. Return pspatialreference;
  11. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Create a geographic coordinate system
  3. /// </Summary>
  4. /// <Param name = "gctype"> esrisrprojcs4type </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference creategeographiccoordinate (esrisrprojcs4type gcstype)
  7. {
  8. Ispatialreferencefactory pspatialreferencefactory = new spatialreferenceenvironmentclass ();
  9. Ispatialreference pspatialreference = pspatialreferencefactory. creategeographiccoordinatesystem (INT) gcstype );
  10. Return pspatialreference;
  11. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Create a projection Coordinate System
  3. /// </Summary>
  4. /// <Param name = "pctype"> esrisrprojcs4type </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference createprojectedcoordinate (esrisrprojcs4type pcstype)
  7. {
  8. Ispatialreferencefactory2 pspatialreferencefactory = new spatialreferenceenvironmentclass ();
  9. Ispatialreference pspatialreference = pspatialreferencefactory. createprojectedcoordinatesystem (INT) pcstype );
  10. Return pspatialreference;
  11. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Obtain an empty projection
  3. /// </Summary>
  4. /// <Returns> </returns>
  5. Public static ispatialreference createunknownspatialreference ()
  6. {
  7. Ispatialreference pspatialreference = new unknowncoordinatesystemclass ();
  8. Pspatialreference. setdomain (0, 99999999, 0, 99999999); // set the Space Range
  9. Return pspatialreference;
  10. }

2. Get space reference

[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Element set space reference
  3. /// </Summary>
  4. /// <Param name = "pfeaturedataset"> element set </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference getspatialreference (ifeaturedataset pfeaturedataset)
  7. {
  8. Igeodataset pgeodataset = pfeaturedataset as igeodataset;
  9. Ispatialreference pspatialreference = pgeodataset. spatialreference;
  10. Return pspatialreference;
  11. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Obtain the element Layer Space reference
  3. /// </Summary>
  4. /// <Param name = "pfeaturelayer"> element layer </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference getspatialreferenc (ifeaturelayer pfeaturelayer)
  7. {Ifeatureclass pfeatureclass = pfeaturelayer. featureclass;
  8. Igeodataset pgeodataset = pfeatureclass as igeodataset;
  9. Ispatialreference pspatialreference = pgeodataset. spatialreference;
  10. Return pspatialreference;
  11. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Element class space reference
  3. /// </Summary>
  4. /// <Param name = "pfeatureclass"> element class </param>
  5. /// <Returns> </returns>
  6. Public static ispatialreference getspatialreference (ifeatureclass pfeatureclass)
  7. {
  8. Igeodataset pgeodataset = pfeatureclass as igeodataset;
  9. Ispatialreference pspatialreference = pgeodataset. spatialreference;
  10. Return pspatialreference;
  11. }

3. Modify space reference

[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Reference for modifying the element set space
  3. /// </Summary>
  4. /// <Param name = "pfeaturedataset"> element set </param>
  5. /// <Param name = "pspatialreference"> New Space reference </param>
  6. Public static void alterspatialreference (ifeaturedataset pfeaturedataset, ispatialreference pspatialreference)
  7. {
  8. Igeodataset pgeodataset = pfeaturedataset as igeodataset;
  9. Igeodatasetschemaedit pgeodatasetschemaedit = pgeodataset as igeodatasetschemaedit;
  10. If (pgeodatasetschemaedit. canalterspatialreference = true)
  11. Pgeodatasetschemaedit. alterspatialreference (pspatialreference );
  12. }
[CSHARP]View plaincopyprint?
  1. /// <Summary>
  2. /// Modify element class space reference
  3. /// </Summary>
  4. /// <Param name = "pfeatureclass"> element class </param>
  5. /// <Param name = "pspatialreference"> New Space reference </param>
  6. Public static void alterspatialreference (ifeatureclass pfeatureclass, ispatialreference pspatialreference)
  7. {
  8. Igeodataset pgeodataset = pfeatureclass as igeodataset;
  9. Igeodatasetschemaedit pgeodatasetschemaedit = pgeodataset as igeodatasetschemaedit;
  10. If (pgeodatasetschemaedit. canalterspatialreference = true)
  11. Pgeodatasetschemaedit. alterspatialreference (pspatialreference );
  12. }

Summary of spatial reference (geographic coordinates) methods in ArcGIS Engine

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.