This document is archived and information here might be outdated. Recommended version. |
Get the spatial reference information of a dataset that is supplied.
///<summary>Get the spatial reference information of a dataset that is supplied.</summary> /// ///<param name="dataset">An IDataset, this could be a table, feature class, feature dataset, workspace etc.</param> /// ///<returns>An ISpatialReference interface if successful, nothing otherwise.</returns> /// ///<remarks></remarks> public ESRI.ArcGIS.Geometry.ISpatialReference GetSpatialReferenceFromDataset(ESRI.ArcGIS.Geodatabase.IDataset dataset) { //If the dataset supports IGeoDataset if (dataset is ESRI.ArcGIS.Geodatabase.IGeoDataset) { //then grab the spatial reference information and return it. ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset=(ESRI.ArcGIS.Geodatabase.IGeoDataset)dataset; return geoDataset.SpatialReference; } else { return null; //otherwise return null } }
'''<summary>Get the spatial reference information of a dataset that is supplied.</summary> ''' '''<param name="dataset">An IDataset, this could be a table, feature class, feature dataset, workspace etc.</param> ''' '''<returns>An ISpatialReference interface if successful, nothing otherwise.</returns> ''' '''<remarks></remarks> Public Function GetSpatialReferenceFromDataset(ByVal dataset As ESRI.ArcGIS.Geodatabase.IDataset) As ESRI.ArcGIS.Geometry.ISpatialReference 'If the dataset supports IGeoDataset If TypeOf dataset Is ESRI.ArcGIS.Geodatabase.IGeoDataset Then 'then grab the spatial reference information and return it. Dim geoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset=CType(dataset, ESRI.ArcGIS.Geodatabase.IGeoDataset) Return geoDataset.SpatialReference Else Return Nothing 'otherwise return nothing End If End Function