Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to build a tool where the user selects a coordinate system for a given CAD file. What is the easiest way to do this with ArcObjects?

Obviously, I could populate a list with the hundreds of projection constants (i.e. esrSRProjCSType), but what user is going to want to scroll through such a huge list? Must be a better way... any tips?


Thanks everybody. I went with the SpatialReferenceDialog approach below. Now, anybody know how to use NewGeoTransformationDialog to apply datum trans?

private void btn_getCs_Click(object sender, EventArgs e)

        string StatusMsg = "";
        bool Status = true;
        SpatialReferenceDialog oSpatialReferenceDialog = null;
        ISpatialReference oSpatialReference = null;
        ISpatialReferenceFactory2 oSpatialReferenceFactory2 = null;
        IGeographicCoordinateSystem oGCS = null;

            oSpatialReferenceFactory2 = (SpatialReferenceEnvironmentClass)new SpatialReferenceEnvironmentClass();
            oGCS = oSpatialReferenceFactory2.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_WGS1984.GetHashCode());
            oSpatialReferenceDialog = new SpatialReferenceDialogClass();
            oSpatialReference = oSpatialReferenceDialog.DoModalEdit(oGCS, false, false, false, false, true, this.Handle.ToInt32());

            txtBx_srDwg.Text = oSpatialReference.Name;
        catch (System.Runtime.InteropServices.COMException CE)
            StatusMsg = CE.ErrorCode.ToString() + ": " + CE.Message;
            Status = false;
        catch (Exception E)
            StatusMsg = E.ToString();
            Status = false;
share|improve this question
At what license level (Engine or Desktop?). – Kirk Kuykendall Aug 22 '11 at 14:30
If your original question was answered, please mark the answer. – kenbuja Aug 30 '11 at 13:59
up vote 6 down vote accepted

You can use the built in SpatialReferenceDialog that allows the user to select the spatial reference. Here's an example built in VB.NET that I use in one of my applications. pSR is set as ESRI.ArcGIS.Geometry.ISpatialReference and SelectSR is a Boolean that I use to check whether the user selected a valid spatial reference. Check for the latest version of each of the interfaces.

Private Sub cmdSetReference_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSetReference.Click

    Dim pSRDialog As ESRI.ArcGIS.CatalogUI.ISpatialReferenceDialog2 = New ESRI.ArcGIS.CatalogUI.SpatialReferenceDialog

    pSR = pSRDialog.DoModalCreate(False, False, False, 0)
    If Not pSR Is Nothing Then
        If Not TypeOf pSR Is ESRI.ArcGIS.Geometry.IGeographicCoordinateSystem2 And Not TypeOf pSR Is ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem5 Then
            System.Windows.Forms.MessageBox.Show("Please select a projected or geographic coordinate system.   ", "Unknown Coordinate System", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Exclamation)
            SelectSR = False
            SelectSR = True
        End If
        SelectSR = False
    End If
End Sub
share|improve this answer
Depends on licensing level, but I would try to use the built in dialog as much as I can. Projections are a complex matter that and if you need to build your own dialog, you will spend some valuable time. – George Aug 22 '11 at 14:34
  1. Initialize an IGxDialog and set its ObjectFilter property to an IGxObjectFilter instantiated with the GxFilterSpatialReferences co-class.
  2. Show the dialog using DoModalOpen()
  3. Get the first IGxObject from the output IEnumGxObject (and check that it is not null).
  4. Cast the IGxObject to IGxPrjFile.
  5. Return its SpatialReference property.

See here for a C# example.

If you need more control over which types of spatial references can be selected, implement IGxObjectFilter in a new class and use it for the IGxDialog's ObjectFilter property instead (see here for a VB6 example).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.