private static ISpatialReference getCustomSpatialRefFromFile() throws Exception {//, ISpatialReference inSpaRef ISpatialReferenceFactory srf = new SpatialReferenceEnvironment(); IProjectedCoordinateSystem pcs = (IProjectedCoordinateSystem) srf.createESRISpatialReferenceFromPRJFile("test.prj"); IProjectedCoordinateSystem4GEN pcsGen = (IProjectedCoordinateSystem4GEN) pcs; IParameter[][] parameters = new IParameter[1][16]; // the 16 is very important. pcsGen.getParameters(parameters); for (int i = 0; i < parameters[0].length; i++){ IParameter currentParameter = parameters[0]; if (currentParameter != null){ System.out.println(currentParameter.getName() + ", " + currentParameter.getIndex() + ", " + currentParameter.getValue()); } // set the value by parameter name if (parameters[0].getName().equals("My_Parameter") == true){IParameter p = parameters[0];p.setValue(0);} } pcs.changed(); for (int i = 0; i < parameters[0].length; i++){ IParameter currentParameter = parameters[0]; if (currentParameter != null) System.out.println(currentParameter.getName() + ", " + currentParameter.getIndex() + ", " + currentParameter.getValue()); } return pcs; }
private static ISpatialReference getCustomSpatialRefFromFile() throws Exception {//, ISpatialReference inSpaRef ISpatialReferenceFactory srf = new SpatialReferenceEnvironment(); IProjectedCoordinateSystem pcs = (IProjectedCoordinateSystem) srf.createESRISpatialReferenceFromPRJFile("test.prj"); IProjectedCoordinateSystem4GEN pcsGen = (IProjectedCoordinateSystem4GEN) pcs; IParameter[][] parameters = new IParameter[1][7]; pcsGen.getParameters(parameters); for (int i = 0; i < parameters[0].length; i++){ IParameter currentParameter = parameters[0]; if (currentParameter != null){ System.out.println(currentParameter.getName() + ", " + currentParameter.getIndex() + ", " + currentParameter.getValue()); } // set the value by parameter name if (parameters[0].getName().equals("My_Parameter") == true){IParameter p = parameters[0];p.setValue(0);} } pcs.changed(); for (int i = 0; i < parameters[0].length; i++){ IParameter currentParameter = parameters[0]; if (currentParameter != null) System.out.println(currentParameter.getName() + ", " + currentParameter.getIndex() + ", " + currentParameter.getValue()); } return pcs; }
Dim pSR As ISpatialReference3 pSR = Nothing Dim t As Type = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment") Dim obj As System.Object = Activator.CreateInstance(t) Dim pSRF As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 = obj ' Create a projection, GeographicCoordinateSystem, and unit using the factory. Dim projection As IProjectionGEN = TryCast(pSRF.CreateProjection(CInt(esriSRProjectionType.esriSRProjection_Sinusoidal)), IProjectionGEN) Dim geographicCoordinateSystem As IGeographicCoordinateSystem = pSRF.CreateGeographicCoordinateSystem(CInt(esriSRGeoCSType.esriSRGeoCS_WGS1984)) Dim unit As ILinearUnit = TryCast(pSRF.CreateUnit(CInt(esriSRUnitType.esriSRUnit_Meter)), ILinearUnit) ' Get the default parameters from the projection. Dim parameters As IParameter() = projection.GetDefaultParameters() ' Create a PCS using the Define method. Dim projectedCoordinateSystemEdit As IProjectedCoordinateSystemEdit = New ProjectedCoordinateSystemClass() Dim Name As Object = "Newfoundland" Dim [Alias] As Object = "NF_LAB" Dim abbreviation As Object = "NF" Dim remarks As Object = "Most Eastern Province in Canada" Dim usage As Object = "When making maps of Newfoundland" Dim geographicCoordinateSystemObject As Object = TryCast(geographicCoordinateSystem, Object) Dim unitObject As Object = TryCast(unit, Object) Dim projectionObject As Object = TryCast(projection, Object) Dim parametersObject As Object = TryCast(parameters, Object) ' Note: Alias is a reserved keyword in VB .NET. To use it as a variable name, encase it in brackets [ ]. projectedCoordinateSystemEdit.Define(Name, [Alias], abbreviation, remarks, usage, geographicCoordinateSystemObject, unitObject, projectionObject, parametersObject) pSR = projectedCoordinateSystemEdit
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.