Problem with projection when creating shapefile from SQL Server database

Jul 19, 2013 at 12:27 AM
Edited Jul 19, 2013 at 12:28 AM
I have an ASP.NET website that allows a user to export a shapefile from one of the selected features which have geodata stored in a SQL Server 2012 database. I am able to export the shapefile successfully, however when I import it into ArcMap, the points are mis-projected onto the map (they are all about 6.6 miles to the northwest of where they should be, to be exact).

I've checked the shapefile's projection information (State Plane Oklahoma North feet), and it looks good:
I've even checked some of the individual points and converted them to lat/lon, and they are correct. Any ideas as to why they aren't projecting right in ArcMap? It seems like the projection may just not be working at all, and not have to do with the specific State Plane coordinate system, because when I use WGS 84 I still have the same problem.

Here is the C# code I use for exporting the shapefile. Thanks!
var featureSet = new FeatureSet(FeatureType.Point);
var dt = _dataAccessLayer.GetTableByFeature(shapeFileName);

// Copy all of the columns from the database table to the feature set
for (int colIdx = 0; colIdx < dt.Columns.Count; colIdx++)
    var col = dt.Columns[colIdx];
    featureSet.DataTable.Columns.Add(new DataColumn(col.ColumnName, 

int rowIndex = 0;
foreach (DataRow row in dt.Rows)
    // Convert the projection from Spherical Mercator to 
    //   NAD1983 State Plane Oklahoma North (feet)
    var vertices = new double[2];
    vertices[0] = Convert.ToDouble(row[COL_X_COORD]);
    vertices[1] = Convert.ToDouble(row[COL_Y_COORD]);
    var z = new double[1];

    Reproject.ReprojectPoints(vertices, z, KnownCoordinateSystems
.Projected.WorldSpheroid.Mercatorsphere, KnownCoordinateSystems.Projected.
StatePlaneNad1983Feet.NAD1983StatePlaneOklahomaNorthFIPS3501Feet, 0, 1);
    featureSet.AddFeature(new Feature(new Coordinate(vertices[0], vertices[1])));

    // Add the rest of the attributes to the feature set
    for (int colIdx = 0; colIdx < dt.Columns.Count - colOffset; colIdx++)
        featureSet.DataTable.Rows[rowIndex][colIdx] = row[colIdx + colOffset];

featureSet.Projection = KnownCoordinateSystems.Projected
featureSet.SaveAs(shapefilePath + shapeFileName, true);
Jul 22, 2013 at 6:20 PM
Ahh, hooray! Figured it out: The mapping product I'm using to map our data refers to the projection I'm using as "Popular Spherical Mercator", which led me to choose "KnownCoordinateSystems .Projected.WorldSpheroid.Mercatorsphere" as the source projection. However, the correct source projection is actually "KnownCoordinateSystems.Projected.World.WebMercator".

The mapping product uses Bing Maps as it's base imagery and from what I was finding online it seems like there's some kind of a blur between referring to the Bing/Google projections as Web Mercator or as Spherical Mercator. Perhaps someone can still enlighten me more about that, but at least as far as my shapefile is concerned, all is better now that I've switched the projection.