public static ISpatialReference ReadSR(string pPrjFilePath) { if (File.Exists(pPrjFilePath)) { StreamReader aReader = new StreamReader(pPrjFilePath); string aLine = aReader.ReadToEnd(); aReader.Close(); int byteCount = 0; if (aLine.StartsWith("GEOGCS")) { GeographicCoordinateSystemClass sr = new GeographicCoordinateSystemClass(); (sr as IESRISpatialReference).ImportFromESRISpatialReference(aLine, out byteCount); return(sr); } else { ProjectedCoordinateSystemClass sr = new ProjectedCoordinateSystemClass(); (sr as IESRISpatialReference).ImportFromESRISpatialReference(aLine, out byteCount); return(sr); } } else { return(null); } }
private void createProjectedCoordinateSystem() { ISpatialReferenceFactory2 spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); IProjectionGEN projection = spatialReferenceFactory.CreateProjection((int)esriSRProjectionType.esriSRProjection_Sinusoidal) as IProjectionGEN; IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); ILinearUnit unit = spatialReferenceFactory.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit; IParameter[] parameters = projection.GetDefaultParameters(); IProjectedCoordinateSystemEdit projectedCoordinateSystemEdit = new ProjectedCoordinateSystemClass(); object name = "Newfoundland"; object alias = "NF_LAB"; object abbreviation = "NF"; object remarks = "Most Eastern Province in Canada"; object usage = "When making maps of Newfoundland"; object geographicCoordinateSystemObject = geographicCoordinateSystem as object; object unitObject = unit as object; object projectionObject = projection as object; object parametersObject = parameters as object; projectedCoordinateSystemEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref geographicCoordinateSystemObject, ref unitObject, ref projectionObject, ref parametersObject); IProjectedCoordinateSystem userDefinedProjectedCoordinateSystem = projectedCoordinateSystemEdit as IProjectedCoordinateSystem; m_map.SpatialReference = userDefinedProjectedCoordinateSystem; m_activeView.Refresh(); MessageBox.Show("自定义ProjectedCoordinateSystem完成!"); }
public ISpatialReference CreateSpatialReferencePCS(string sSRString) { try { if (string.IsNullOrEmpty(sSRString)) { return(null); } IESRISpatialReference reference = null; reference = new ProjectedCoordinateSystemClass(); int cBytesRead = 0; reference.ImportFromESRISpatialReference(sSRString, out cBytesRead); return(reference as ISpatialReference); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.GeometryFun", "CreateSpatialReferencePCS", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(null); } }
public static ISpatialReference ReadSR(string pPrjFilePath) { if (File.Exists(pPrjFilePath)) { StreamReader aReader = new StreamReader(pPrjFilePath); string aLine = aReader.ReadToEnd(); aReader.Close(); int byteCount = 0; if (aLine.StartsWith("GEOGCS")) { GeographicCoordinateSystemClass sr = new GeographicCoordinateSystemClass(); (sr as IESRISpatialReference).ImportFromESRISpatialReference(aLine, out byteCount); return sr; } else { ProjectedCoordinateSystemClass sr = new ProjectedCoordinateSystemClass(); (sr as IESRISpatialReference).ImportFromESRISpatialReference(aLine, out byteCount); return sr; } } else { return null; } }
public void Execute() { try { // Create new spatial reference ISpatialReference spatialReference = null; if (this.SRef.ToLowerInvariant().Contains("projcs")) { spatialReference = new ProjectedCoordinateSystemClass(); } else { spatialReference = new GeographicCoordinateSystemClass(); } // Import SpatialReference Definition int bytes2; IESRISpatialReferenceGEN2 gen = (IESRISpatialReferenceGEN2)spatialReference; gen.ImportFromESRISpatialReference(this.SRef, out bytes2); // Create Search Extent IEnvelope extent = new EnvelopeClass(); extent.PutCoords(this.XMin, this.YMin, this.XMax, this.YMax); extent.SpatialReference = spatialReference; // Open Saved Layer File ILayerFile layerFile = new LayerFileClass(); layerFile.Open(this.Path); ILayer layer = layerFile.Layer; layerFile.Close(); // Where clause and list of selected OIDs string where = string.Empty; List <int> ids = new List <int>(); IImageServerLayer imageLayer = null; if (layer is IImageServerLayer) { imageLayer = (IImageServerLayer)layer; // Get Selection Set IFeatureLayerDefinition definition = layer as IFeatureLayerDefinition; if (definition != null) { // Find Selected OIDs if (definition.DefinitionSelectionSet != null) { if (definition.DefinitionSelectionSet.Count > 0) { IEnumIDs emumids = definition.DefinitionSelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } // Update Where Clause if (!string.IsNullOrEmpty(definition.DefinitionExpression)) { where = definition.DefinitionExpression; } } } else if (layer is IMosaicLayer) { IMosaicLayer mosaicLayer = (IMosaicLayer)layer; imageLayer = mosaicLayer.PreviewLayer; ITableDefinition tableDefinition = mosaicLayer as ITableDefinition; if (tableDefinition != null) { // Find Selected OIDs if (tableDefinition.DefinitionSelectionSet != null) { if (tableDefinition.DefinitionSelectionSet.Count > 0) { IEnumIDs emumids = tableDefinition.DefinitionSelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } // Update Where Clause if (!string.IsNullOrEmpty(tableDefinition.DefinitionExpression)) { where = tableDefinition.DefinitionExpression; } } } // Use FeatureSelected (if any) IFeatureSelection featureSelection = imageLayer as IFeatureSelection; if (featureSelection != null) { if (featureSelection.SelectionSet != null) { if (featureSelection.SelectionSet.Count > 0) { IEnumIDs emumids = featureSelection.SelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } } // Get Bands ILongArray bands = new LongArrayClass(); IRasterRenderer rasterRenderer = imageLayer.Renderer; if (rasterRenderer != null) { IRasterRGBRenderer2 rasterRGBRenderer = rasterRenderer as IRasterRGBRenderer2; if (rasterRGBRenderer != null) { bands.Add(rasterRGBRenderer.UseRedBand ? rasterRGBRenderer.RedBandIndex : -1); bands.Add(rasterRGBRenderer.UseGreenBand ? rasterRGBRenderer.GreenBandIndex : -1); bands.Add(rasterRGBRenderer.UseBlueBand ? rasterRGBRenderer.BlueBandIndex : -1); bands.Add(rasterRGBRenderer.UseAlphaBand ? rasterRGBRenderer.AlphaBandIndex : -1); } } // Create Spatial Filter ISpatialFilter spatialFilter = new SpatialFilterClass() { Geometry = extent, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects, WhereClause = where }; IImageServer imageServer = imageLayer.DataSource as IImageServer; if (imageServer == null) { return; } IImageServer3 imageServer3 = imageServer as IImageServer3; if (imageServer3 == null) { return; } IRecordSet recordSet = imageServer3.GetCatalogItems(spatialFilter); ICursor cursor = recordSet.get_Cursor(false); IFeatureCursor featureCursor = (IFeatureCursor)cursor; IFeature feature = featureCursor.NextFeature(); List <IFeature> list = new List <IFeature>(); int indexCategory = featureCursor.FindField("Category"); while (feature != null) { // Exclude non-primary images (no overviews) if (indexCategory != -1) { int cat = (int)feature.get_Value(indexCategory); if (cat != 1) { feature = featureCursor.NextFeature(); continue; } } // Exclude unselected features if (ids.Count > 0) { int oid = feature.OID; if (!ids.Contains(oid)) { feature = featureCursor.NextFeature(); continue; } } list.Add(feature); feature = featureCursor.NextFeature(); } // If nothing, fire event then exit if (list.Count == 0) { this.OnThumbnailSummary(new SummaryEventArgs()); return; } // Get Full Extent of Features SummaryEventArgs summary = new SummaryEventArgs() { XMin = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).XMin), YMin = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).YMin), XMax = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).XMax), YMax = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).YMax), Count = list.Count }; // Add Fields IFields fields = featureCursor.Fields; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeGlobalID: case esriFieldType.esriFieldTypeGUID: case esriFieldType.esriFieldTypeRaster: case esriFieldType.esriFieldTypeXML: break; case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeDate: case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: case esriFieldType.esriFieldTypeString: summary.Fields.Add( new Field() { Name = field.Name, Alias = field.AliasName, Type = field.Type } ); break; default: break; } } // Raise Summary Event this.OnThumbnailSummary(summary); // Loop for each feature foreach (IFeature feat in list) { // Project Extent to Current Map Spatial Reference IEnvelope extentMap = feat.Shape.Envelope.CloneProject(spatialReference); int width; int height; if (extentMap.Width > extentMap.Height) { width = this.MaxImageSize; height = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Height / (double)extentMap.Width); } else { width = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Width / (double)extentMap.Height); height = this.MaxImageSize; } IMosaicRule mosaicRule = new MosaicRuleClass() { MosaicMethod = esriMosaicMethod.esriMosaicLockRaster, LockRasterID = feat.OID.ToString() }; IGeoImageDescription geoImageDescription = new GeoImageDescriptionClass() { BandSelection = bands.Count > 0 ? bands : null, MosaicRule = mosaicRule, Compression = "PNG", Width = width, Height = height, SpatialReference = spatialReference, Extent = extentMap, Interpolation = rstResamplingTypes.RSP_BilinearInterpolation, }; // Assembly MosaicRequest (will be executed in background thread) MosaicRequest mosaicRequest = new MosaicRequest() { MosaicExtractor = this, ImageServer = imageServer3, GeoImageDescription = geoImageDescription, XMin = extentMap.XMin, YMin = extentMap.YMin, XMax = extentMap.XMax, YMax = extentMap.YMax, }; // Add Attributes Names and Values foreach (Field field in summary.Fields) { int index = feat.Fields.FindField(field.Name); if (index < 0) { continue; } mosaicRequest.Attributes.Add(field.Name, feat.get_Value(index)); } // Start Mosaic Request in Background Thread Thread thread = new Thread(new ThreadStart(mosaicRequest.Execute)); MosaicEnvironment.Default.Threads.Add(thread); thread.Start(); } } catch { } }
//将任意坐标系统转换为自定义Albers大地坐标(米) public static IPoint GeoToGra(IPoint point) { IPoint pt = new PointClass(); pt.PutCoords(point.X, point.Y); ISpatialReferenceFactory2 pFact = new SpatialReferenceEnvironmentClass(); //定义地理坐标,由输入的对象决定,也可以自己定义,参考: esriSRGeoCSType IGeographicCoordinateSystem pGCS = new GeographicCoordinateSystemClass(); pGCS = pFact.CreateGeographicCoordinateSystem(point.SpatialReference.FactoryCode); //自定义投影方式 IProjectedCoordinateSystem pProjectedCS = new ProjectedCoordinateSystemClass(); IProjectedCoordinateSystemEdit pProjectedCSEdit = pProjectedCS as IProjectedCoordinateSystemEdit; //定义投影方式,参考: esriSRProjectionType IProjection pProjection = new ProjectionClass(); pProjection = pFact.CreateProjection((int)esriSRProjectionType.esriSRProjection_Albers); //定义投影单位,参考:esriSRUnitType ILinearUnit pUnit = new LinearUnitClass(); pUnit = pFact.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit; //定义其他参数,参考:esriSRParameterType IParameter[] pParm = new IParameter[6]; pParm[0] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseEasting); pParm[0].Value = 0; pParm[1] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseNorthing); pParm[1].Value = 0; pParm[2] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_CentralMeridian); pParm[2].Value = 110; pParm[3] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel1); pParm[3].Value = 25; pParm[4] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel2); pParm[4].Value = 47; pParm[5] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_LatitudeOfOrigin); pParm[5].Value = 0; //设置投影相关信息 object name = "User_Defined_Albers"; object alias = "Albers"; object abbreviation = "Albers"; object remarks = "User_Defined_Albers is the projection"; object usage = ""; object gcs = pGCS; object projectedUnit = pUnit; object projection = pProjection; object parameters = pParm; pProjectedCSEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref gcs, ref projectedUnit, ref projection, ref parameters); //获取自定义空间参考 ISpatialReference pSpatialRef = pProjectedCS as ISpatialReference; IGeometry pGeometry = (IGeometry)pt; pGeometry.SpatialReference = pGCS as ISpatialReference; //重投影处理 pGeometry.Project(pSpatialRef); return pt; }
public void Execute() { try { // Create new spatial reference ISpatialReference spatialReference = null; if (this.SRef.ToLowerInvariant().Contains("projcs")) { spatialReference = new ProjectedCoordinateSystemClass(); } else { spatialReference = new GeographicCoordinateSystemClass(); } // Import SpatialReference Definition int bytes2; IESRISpatialReferenceGEN2 gen = (IESRISpatialReferenceGEN2)spatialReference; gen.ImportFromESRISpatialReference(this.SRef, out bytes2); // Create Search Extent IEnvelope extent = new EnvelopeClass(); extent.PutCoords(this.XMin, this.YMin, this.XMax, this.YMax); extent.SpatialReference = spatialReference; // Open Saved Layer File ILayerFile layerFile = new LayerFileClass(); layerFile.Open(this.Path); ILayer layer = layerFile.Layer; layerFile.Close(); // Where clause and list of selected OIDs string where = string.Empty; List<int> ids = new List<int>(); IImageServerLayer imageLayer = null; if (layer is IImageServerLayer) { imageLayer = (IImageServerLayer)layer; // Get Selection Set IFeatureLayerDefinition definition = layer as IFeatureLayerDefinition; if (definition != null) { // Find Selected OIDs if (definition.DefinitionSelectionSet != null) { if (definition.DefinitionSelectionSet.Count > 0) { IEnumIDs emumids = definition.DefinitionSelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } // Update Where Clause if (!string.IsNullOrEmpty(definition.DefinitionExpression)) { where = definition.DefinitionExpression; } } } else if (layer is IMosaicLayer) { IMosaicLayer mosaicLayer = (IMosaicLayer)layer; imageLayer = mosaicLayer.PreviewLayer; ITableDefinition tableDefinition = mosaicLayer as ITableDefinition; if (tableDefinition != null) { // Find Selected OIDs if (tableDefinition.DefinitionSelectionSet != null) { if (tableDefinition.DefinitionSelectionSet.Count > 0) { IEnumIDs emumids = tableDefinition.DefinitionSelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } // Update Where Clause if (!string.IsNullOrEmpty(tableDefinition.DefinitionExpression)) { where = tableDefinition.DefinitionExpression; } } } // Use FeatureSelected (if any) IFeatureSelection featureSelection = imageLayer as IFeatureSelection; if (featureSelection != null) { if (featureSelection.SelectionSet != null) { if (featureSelection.SelectionSet.Count > 0) { IEnumIDs emumids = featureSelection.SelectionSet.IDs; int id = emumids.Next(); while (id != -1) { ids.Add(id); id = emumids.Next(); } } } } // Get Bands ILongArray bands = new LongArrayClass(); IRasterRenderer rasterRenderer = imageLayer.Renderer; if (rasterRenderer != null) { IRasterRGBRenderer2 rasterRGBRenderer = rasterRenderer as IRasterRGBRenderer2; if (rasterRGBRenderer != null) { bands.Add(rasterRGBRenderer.UseRedBand ? rasterRGBRenderer.RedBandIndex : -1); bands.Add(rasterRGBRenderer.UseGreenBand ? rasterRGBRenderer.GreenBandIndex : -1); bands.Add(rasterRGBRenderer.UseBlueBand ? rasterRGBRenderer.BlueBandIndex : -1); bands.Add(rasterRGBRenderer.UseAlphaBand ? rasterRGBRenderer.AlphaBandIndex : -1); } } // Create Spatial Filter ISpatialFilter spatialFilter = new SpatialFilterClass() { Geometry = extent, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects, WhereClause = where }; IImageServer imageServer = imageLayer.DataSource as IImageServer; if (imageServer == null) { return; } IImageServer3 imageServer3 = imageServer as IImageServer3; if (imageServer3 == null) { return; } IRecordSet recordSet = imageServer3.GetCatalogItems(spatialFilter); ICursor cursor = recordSet.get_Cursor(false); IFeatureCursor featureCursor = (IFeatureCursor)cursor; IFeature feature = featureCursor.NextFeature(); List<IFeature> list = new List<IFeature>(); int indexCategory = featureCursor.FindField("Category"); while (feature != null) { // Exclude non-primary images (no overviews) if (indexCategory != -1) { int cat = (int)feature.get_Value(indexCategory); if (cat != 1) { feature = featureCursor.NextFeature(); continue; } } // Exclude unselected features if (ids.Count > 0) { int oid = feature.OID; if (!ids.Contains(oid)) { feature = featureCursor.NextFeature(); continue; } } list.Add(feature); feature = featureCursor.NextFeature(); } // If nothing, fire event then exit if (list.Count == 0) { this.OnThumbnailSummary(new SummaryEventArgs()); return; } // Get Full Extent of Features SummaryEventArgs summary = new SummaryEventArgs() { XMin = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).XMin), YMin = list.Min(f => f.Shape.Envelope.CloneProject(spatialReference).YMin), XMax = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).XMax), YMax = list.Max(f => f.Shape.Envelope.CloneProject(spatialReference).YMax), Count = list.Count }; // Add Fields IFields fields = featureCursor.Fields; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeGlobalID: case esriFieldType.esriFieldTypeGUID: case esriFieldType.esriFieldTypeRaster: case esriFieldType.esriFieldTypeXML: break; case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeDate: case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: case esriFieldType.esriFieldTypeString: summary.Fields.Add( new Field() { Name = field.Name, Alias = field.AliasName, Type = field.Type } ); break; default: break; } } // Raise Summary Event this.OnThumbnailSummary(summary); // Loop for each feature foreach (IFeature feat in list) { // Project Extent to Current Map Spatial Reference IEnvelope extentMap = feat.Shape.Envelope.CloneProject(spatialReference); int width; int height; if (extentMap.Width > extentMap.Height) { width = this.MaxImageSize; height = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Height / (double)extentMap.Width); } else { width = Convert.ToInt32((double)this.MaxImageSize * (double)extentMap.Width / (double)extentMap.Height); height = this.MaxImageSize; } IMosaicRule mosaicRule = new MosaicRuleClass() { MosaicMethod = esriMosaicMethod.esriMosaicLockRaster, LockRasterID = feat.OID.ToString() }; IGeoImageDescription geoImageDescription = new GeoImageDescriptionClass() { BandSelection = bands.Count > 0 ? bands : null, MosaicRule = mosaicRule, Compression = "PNG", Width = width, Height = height, SpatialReference = spatialReference, Extent = extentMap, Interpolation = rstResamplingTypes.RSP_BilinearInterpolation, }; // Assembly MosaicRequest (will be executed in background thread) MosaicRequest mosaicRequest = new MosaicRequest() { MosaicExtractor = this, ImageServer = imageServer3, GeoImageDescription = geoImageDescription, XMin = extentMap.XMin, YMin = extentMap.YMin, XMax = extentMap.XMax, YMax = extentMap.YMax, }; // Add Attributes Names and Values foreach (Field field in summary.Fields) { int index = feat.Fields.FindField(field.Name); if (index < 0) { continue; } mosaicRequest.Attributes.Add(field.Name, feat.get_Value(index)); } // Start Mosaic Request in Background Thread Thread thread = new Thread(new ThreadStart(mosaicRequest.Execute)); MosaicEnvironment.Default.Threads.Add(thread); thread.Start(); } } catch { } }
//将任意坐标系统转换为自定义Albers大地坐标(米) public static IPoint GeoToGra(IPoint point) { IPoint pt = new PointClass(); pt.PutCoords(point.X, point.Y); ISpatialReferenceFactory2 pFact = new SpatialReferenceEnvironmentClass(); //定义地理坐标,由输入的对象决定,也可以自己定义,参考: esriSRGeoCSType IGeographicCoordinateSystem pGCS = new GeographicCoordinateSystemClass(); pGCS = pFact.CreateGeographicCoordinateSystem(point.SpatialReference.FactoryCode); //自定义投影方式 IProjectedCoordinateSystem pProjectedCS = new ProjectedCoordinateSystemClass(); IProjectedCoordinateSystemEdit pProjectedCSEdit = pProjectedCS as IProjectedCoordinateSystemEdit; //定义投影方式,参考: esriSRProjectionType IProjection pProjection = new ProjectionClass(); pProjection = pFact.CreateProjection((int)esriSRProjectionType.esriSRProjection_Albers); //定义投影单位,参考:esriSRUnitType ILinearUnit pUnit = new LinearUnitClass(); pUnit = pFact.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit; //定义其他参数,参考:esriSRParameterType IParameter[] pParm = new IParameter[6]; pParm[0] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseEasting); pParm[0].Value = 0; pParm[1] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseNorthing); pParm[1].Value = 0; pParm[2] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_CentralMeridian); pParm[2].Value = 110; pParm[3] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel1); pParm[3].Value = 25; pParm[4] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel2); pParm[4].Value = 47; pParm[5] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_LatitudeOfOrigin); pParm[5].Value = 0; //设置投影相关信息 object name = "User_Defined_Albers"; object alias = "Albers"; object abbreviation = "Albers"; object remarks = "User_Defined_Albers is the projection"; object usage = ""; object gcs = pGCS; object projectedUnit = pUnit; object projection = pProjection; object parameters = pParm; pProjectedCSEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref gcs, ref projectedUnit, ref projection, ref parameters); //获取自定义空间参考 ISpatialReference pSpatialRef = pProjectedCS as ISpatialReference; IGeometry pGeometry = (IGeometry)pt; pGeometry.SpatialReference = pGCS as ISpatialReference; //重投影处理 pGeometry.Project(pSpatialRef); return(pt); }