I do not want to use ArcMap or any other ESRI tool except ArcObjects to accomplish this task. Another open source solution would also be fine.

I need to convert geometry data from ArcGIS using SQL server to WGS84. I have some code to do a specific projection but I don't know how to apply this to an unknown projection without manually changing the code. As I said the data I need to convert is in an ESRI SQL server. I've looked through the SDE tables and see basically how ESRI stores the data. My question is what table holds the EPSG for the stored projection for a given feature class table so that I can properly provide the esriSRGeoCSType? What esriSRProjCSType do I use for standard lat lon (WGS84) North America?

My goal is to write a simple routine that you can point to a ESRI SQL server, the user selects the feature class table they want to convert and the routine spits out the data along with the geometry projected to WGS84. The original projection is unknown and will have to be retrieved from the ESRI SQL server. Once the user selects the table, the selection is stored the process will continue to run as a service and the process will happen on a timed interval so it needs to be done without further user interaction. Maybe I'm going about it all wrong, I'm a little lost at this point.

UPDATE - RESOLVED Here is the working code to reproject one coordinate system to another. In this case I'm using NJ state plane to WGS84 Lat and Long.

            int inEPSG = 3424;
            int outEPSG = 4326;

            ISpatialReferenceFactory2 srFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference ProjectedSR = srFactory.CreateSpatialReference(outEPSG);
            ISpatialReference GeographicSR = srFactory.CreateSpatialReference(inEPSG);

            double xCoord = 547326.03872482851;
            double yCoord = 541395.50404749066;

            IPoint geographicPoint = new PointClass();
            geographicPoint.PutCoords(xCoord, yCoord);
            geographicPoint.SpatialReference = GeographicSR;


            var _gcsLat = geographicPoint.Y;
            var _gcsLong = geographicPoint.X;

To get the current EPSG for a particular geometry column in an ESRI geo-enabled database you can retrieve it from the table SDE_geometry_columns. It has a FK relationship to SDE_spatial_references using the srid column. The column auth_srid in SDE_spatial_references will have the EPSG used for that column's coordinate system.

As I thought it was very simple.

  • 1
    There is no such thing as an Esri SQL Server. Do you mean a geodatabase-enabled Microsoft SQL Server database? Even if this question was clear, I think it would still be too broad for our "Focused question / best answer" model -- It seems as if you're looking for six or seven hundred lines to be added to the score you have here (though it might be as many as a few thousand; it depends on the implementation). See the Tour for details on how GIS SE usually operates. – Vince Nov 28 '17 at 23:37
  • OK, I meant ESRI using SQL Server. Seems a bit strange it would take 6 or 700 lines of code to accomplish something so simple. What good is paying 3k for arc objects if I have to basically write my own projection routines. I can do this manually by using the math, though it is a bit complex and it still would be under a couple of thousand lines of code. – user3478586 Nov 28 '17 at 23:49
  • btw, I'm not asking someone to write the retrival, storage or service. I was providing that information so someone didn't just say "Well, you can easily do that in ArcMap". – user3478586 Nov 28 '17 at 23:51
  • There is nothing simple about taking arbitrary data and reprojecting it to an unspecified format. ArcMap is the wrong product for comparison; ArcGIS Server is the package that makes this possible out-of-the-box. Except that the existing functionality can't process arbitrary input, so now you're writing a custom geoprocessing service (which would only be a hundred lines in Python) or a server object extension (SOE), the empty template for which runs several hundred lines. – Vince Nov 29 '17 at 0:04
  • How did the data get into SQL? If the data was stored by SDE you will probably need Esri to descramble it; if your data is SQLSpatial data then you could be able to use GDAL/OGR. Geometry objects should know what their spatial reference is, so it's only needed to supply the 'to' spatial reference to project provided there is no custom transform required. To make a spatial reference from an EPSG code have a look at ISpatialReferenceFactory2.CreateSpatialReference resources.arcgis.com/en/help/arcobjects-net/componenthelp/… – Michael Stimson Nov 29 '17 at 1:58