2

I have a number of Polyline and Point features stored in a SQL Server 2012 database. I am using a website with C# and DotSpatial to create and export a shapefile of any one of these features successfully, however when I import the file 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 have checked some of the individual points by converting them to lat/lon, and they are exactly what they should be. I've checked the shapefile's projection information (NAD83 State Plane Oklahoma North feet), and it looks good:

PROJCS["NAD_1983_StatePlane_Oklahoma_North_FIPS_3501_Feet",
GEOGCS["GCS_North_American_1983",
DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],
PARAMETER["False_Easting",1968500.0],PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",-98.0],
PARAMETER["Standard_Parallel_1",35.56666666666667],
PARAMETER["Standard_Parallel_2",36.76666666666667],
PARAMETER["Latitude_Of_Origin",35.0],UNIT["Foot_US",0.3048006096012192]]

I have a different shapefile of the same points that was created using a different third-party tool that is displaying in ArcMap correctly. I've checked the projection information for both files and they both have the above projection information.

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, 
        col.DataType));
}

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];
    }
    rowIndex++;
}

featureSet.Projection = KnownCoordinateSystems.Projected
    .StatePlaneNad1983Feet.NAD1983StatePlaneOklahomaNorthFIPS3501Feet;
featureSet.SaveAs(shapefilePath + shapeFileName, true);
2
  • 2
    Can you identify the same point in both shapefiles and pull its coordinates? The CRS wkt looks fine to me, but 6.6 miles seems like a feet vs meters issue.
    – mkennedy
    Commented Jul 19, 2013 at 17:17
  • Thanks for the reply, and sorry for the delayed response. That sounds like it could definitely be the issue. Here is a point from the original shapefile: (2044241.39049, 220193.458573), and here is that same point from the newly-exported shapefile: (2011671.21719, 232770.630536), both in NAD83 Oklahoma North feet (or at least supposed to be). Am I supposed to be doing a meters-to-feet conversion when reprojecting from Spherical Mercator (which is using meters) to State Plane (which is using feet)?
    – cearly
    Commented Jul 22, 2013 at 15:21

1 Answer 1

3

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.

1
  • 2
    Great. Will you please mark this as the accepted answer (you may have to wait a day) so that future readers will quickly know that this is how to solve it?
    – user3461
    Commented Jul 22, 2013 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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