ESRI.ArcGIS.ADF.IMS
SpatialReference Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.SpatialReference Namespace : SpatialReference Class




Class containing the properties for a coordinate system and a datum transformation.

Object Model



Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class SpatialReference 
Visual Basic (Usage)Copy Code
Dim instance As SpatialReference
C# 
[SerializableAttribute()]
public class SpatialReference 

Example

The following example defines a SpatialReference for transforming a data set with one projection and datum, so that the data can be used in a map with a different projection and datum. In this case, the map is in WGS 1984 geographic coordinates (but could be any projection/datum, as long as it is defined in the map service). We are adding a dynamic layer that uses data in Old Hawaiian State Plane (Zone 3), which uses a different datum (Old Hawaiian) than WGS 1984. Therefore, both the coordinate system and datum need to be defined for proper alignment of data. Once the SpatialReference is defined, the dynamic layer is defined and its SpatialReference is set, and the layer is added to the map. The code assumes an existing MapView object.
C#Copy Code
// Define the spatial reference of the layer 

// The datum transformation - Old Hawaiian to WGS84 (Oahu) 

ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo layerDatumTransformation = 

    new ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo(108012); 

  

// The coordinate system - Old_Hawaiian_StatePlane_Hawaii_3_FIPS_5103 

ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo layerCoordSys = 

    new ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo(3563); 

  

// The spatial reference, using the datum transformation and coordinate system 

ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference layerSpatialRef = 

    new ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(); 

layerSpatialRef.DatumTransformation = layerDatumTransformation; 

layerSpatialRef.CoordinateSystem = layerCoordSys; 

  

// Create a new FeatureLayer from a new shapeworkspace and data set 

ESRI.ArcGIS.ADF.IMS.Data.ShapeWorkspace newWS = 

    new ESRI.ArcGIS.ADF.IMS.Data.ShapeWorkspace("OahuWS", @"D:\Data"); 

ESRI.ArcGIS.ADF.IMS.Data.FeatureDataset newDataset =  

    new ESRI.ArcGIS.ADF.IMS.Data.FeatureDataset("Oahu", newWS); 

ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureLayer dynamicLayer =  

    new ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureLayer("OahuCoastline", newDataset); 

dynamicLayer.Type = ESRI.ArcGIS.ADF.IMS.FeatureType.Polygon; 

  

// Set the spatial reference by the property in the dataset 

newDataset.SpatialReference = layerSpatialRef; 

  

// Assign a new renderer to the dynamic layer 

ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer layerRenderer =  

    ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer.Create( 

    ESRI.ArcGIS.ADF.IMS.FeatureType.Polygon, System.Drawing.Color.Green); 

dynamicLayer.Renderer = layerRenderer; 

  

// Add the dynamic layer to the map and draw the map 

mapView.Layers.Add(dynamicLayer); 

    
Visual BasicCopy Code
' Define the spatial reference of the layer

' The datum transformation - Old Hawaiian to WGS84 (Oahu)

Dim layerDatumTransformation As New _

    ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo(108012)



' The coordinate system - Old_Hawaiian_StatePlane_Hawaii_3_FIPS_5103

Dim layerCoordSys As New _

    ESRI.ArcGIS.ADF.IMS.SpatialReference.IDSpatialReferenceInfo(3563)



' The spatial reference, using the datum transformation and coordinate system

Dim layerSpatialRef As New _

    ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference()

layerSpatialRef.DatumTransformation = layerDatumTransformation

layerSpatialRef.CoordinateSystem = layerCoordSys



' Create a new FeatureLayer from a new shapeworkspace and data set

Dim newWS As New _

    ESRI.ArcGIS.ADF.IMS.Data.ShapeWorkspace("OahuWS", "D:\Data")

Dim newDataset As New _

    ESRI.ArcGIS.ADF.IMS.Data.FeatureDataset("Oahu", newWS)

Dim dynamicLayer As New _

    ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureLayer("OahuCoastline", newDataset)

dynamicLayer.Type = ESRI.ArcGIS.ADF.IMS.FeatureType.Polygon



' Set the spatial reference by the property in the dataset

newDataset.SpatialReference = layerSpatialRef



' Assign a new renderer to the dynamic layer

Dim layerRenderer As ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer = _

    ESRI.ArcGIS.ADF.IMS.Display.Renderer.SimpleRenderer.Create( _

    ESRI.ArcGIS.ADF.IMS.FeatureType.Polygon, System.Drawing.Color.Green)

dynamicLayer.Renderer = layerRenderer



' Add the dynamic layer to the map and draw the map

mapView.Layers.Add(dynamicLayer)

Remarks

SpatialReference can be used to define the coordinate system (projection) and optionally the datum transformation for many map elements, including:

  • MapService - the spatial reference of the ArcIMS map service
  • MapView - get or set the projection of the map
  • DataFrame - the spatial reference of an ArcMap image service data frame
  • QueryParameters - the spatial reference for the query output
  • FeatureDataset and ImageDataset - the spatial reference for a dynamically added layer
  • Classes that extend Geometry, such as Envelope - the projection for querying or displaying with geometry.

Not every instance of these classes will have or require a SpatialReference. SpatialReference is most commonly employed when multiple coordinate systems or datums are used within the application.

A SpatialReference normally includes a CoordinateSystem setting. The coordinate system defines how latitude-longitude coordinates are transformed onto 2-dimension x-y coordinates. The SpatialReference may also include a DatumTransformation, which defines a tranformation to or from the WGS84 ellipsoid.

The CoordinateSystem and DatumTransformation may be set either using an integer ID value or with a definition string. Commonly used projections and datum transformations have been assigned ID values. Use IDSpatialReferenceInfo when setting the coordinate system or datum transformation by ID. Definition strings allow flexibility to set parameters for the coordinate system or datum transformation. Use DefinitionSpatialReferenceInfo to set the coordinate system or datum transformation with a definition string.

If an ID value is available for the coordinate system or datum transformation, it is normally more convenient to use the ID rather than the definition string. If a custom projection is needed, such as for a non-standard central meridian, it may be necessary to use the definition string.

A SpatialReference returned by the ArcIMS server for a MapService or MapView will use DefinitionSpatialReferenceInfo for coordinate system and datum transformation (if included).

See ArcIMS Help, under ArcXML Guide, for IDs and definition strings for particular coordinate systems and datum transformations. Also see ArcIMS Help for general information on coordinate systems and datum transformations.

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference

See Also

© 2010 All Rights Reserved.