Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?How to programmatically determine whether a spatial reference factory code is valid?

Edit: This is after the fact, but I have become aware of this answerthis answer

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?

Edit: This is after the fact, but I have become aware of this answer

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?

Edit: This is after the fact, but I have become aware of this answer

Added helpful link
Source Link
TSJ
  • 3.4k
  • 2
  • 27
  • 45

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?

Edit: This is after the fact, but I have become aware of this answer

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?

Edit: This is after the fact, but I have become aware of this answer

Source Link
TSJ
  • 3.4k
  • 2
  • 27
  • 45

Proper way to check if a Factory Code is Projected or Geographic

I would like to create a SpatialReference with ArcObjects, but I won't know whether it is Projected or Geographic, I'll only have the SRID. Is it fine practice to use 'ISpatialReferenceFactory.CreateGeographicCoordinateSystem' with a 'try', see if it fails, and if so, use 'CreateProjectedCoordinateSystem', and if that fails, give a message that it won't work? I have a feeling that I shouldn't use Exceptions in this way, but I'm not aware of an alternative.

I am aware of these answers, but they don't quite answer the question:

Determining if spatial reference Geographic or Projected using ArcObjects?

How to programmatically determine whether a spatial reference factory code is valid?