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);