Summary of methods related to spatial references (geographical coordinates) in the ArcGIS engine

Source: Internet
Author: User

A summary of the methods related to spatial references (geographical coordinates) in the original ArcGIS engine

1. Create a spatial reference

[CSharp]View Plaincopy print?
  1. <summary>
  2. Create a spatial reference based on the prj file
  3. </summary>
  4. <param name= "Strprofile" > Spatial reference Files </param>
  5. <returns></returns>
  6. Public static Ispatialreference createspatialreference (string strprofile)
  7. {
  8. Ispatialreferencefactory pspatialreferencefactory = new Spatialreferenceenvironmentclass ();
  9. Ispatialreference pspatialreference = Pspatialreferencefactory.createesrispatialreferencefromprjfile (strProFile);
  10. return pspatialreference;
  11. }
[CSharp]View Plaincopy print?
  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 Plaincopy print?
  1. <summary>
  2. Create a projected 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 Plaincopy print?
  1. <summary>
  2. Get 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 Space range
  9. return pspatialreference;
  10. }

2. Get a spatial reference

[CSharp]View Plaincopy print?
  1. <summary>
  2. Get feature set spatial reference
  3. </summary>
  4. <param name= "Pfeaturedataset" > Feature 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 Plaincopy print?
  1. <summary>
  2. Get feature layer spatial reference
  3. </summary>
  4. <param name= "Pfeaturelayer" > Feature 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 Plaincopy print?
  1. <summary>
  2. Get feature class spatial reference
  3. </summary>
  4. <param name= "Pfeatureclass" > Feature 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 the spatial reference

[CSharp]View Plaincopy print?
  1. <summary>
  2. Modifying a feature set spatial reference
  3. </summary>
  4. <param name= "Pfeaturedataset" > Feature 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 Plaincopy print?
  1. <summary>
  2. Modifying a feature class spatial reference
  3. </summary>
  4. <param name= "Pfeatureclass" > Feature 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 methods related to spatial references (geographical coordinates) in the 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.