At work I’m currently working on a fun project called SchetsGIS. Spatial planners are still printing maps and draw on overlays, the idea is to make the lives of the planners and other involved people a little bit easier by using the Microsoft Surface table for this. The project contains some nice features, I will put up a video here later when I’m done with the first version. One of the features is to export the drawings usable within a GIS package for further processing, for now it is only .shp and .kml but probably there will be other extensions added in a later stadium like .mxd and .lyr.
While browsing the internet in search for how to write a shapefile in .Net I only saw some open-source libraries for reading shapefiles but not writing until I came across http://www.easygisdotnet.com/
This is taken from their site:
Easy GIS .NET is a suite of .NET 2.0 GIS and mapping tools and controls to let developers easily incorporate GIS functionality into their applications. Our tools currently support ESRI shapefile format.
If you are looking for a free .NET Shapefile library don’t pay expensive licensing costs for a product that may not give you the same benefits of Easy GIS .NET. Not only is our Desktop version of Easy GIS .NET FREE, you may just find it outperforms expensive commercial software.
Here’s a small snippet how to write a shapefile:
DbfFieldDesc[] fields = new DbfFieldDesc[]
{
new DbfFieldDesc { FieldName = "ID", FieldType = DbfFieldType.Number, FieldLength = 1, RecordOffset = 0 },
new DbfFieldDesc { FieldName = "TestField", FieldType = DbfFieldType.Character, FieldLength = 255, RecordOffset = 1 }
};
ShapeFileWriter shpWriter = ShapeFileWriter.CreateWriter(shpFilePath, shapeName, ShapeType.Polygon, fields);
foreach (Feature feature in featureList)
{
string[] fieldData = new string[]
{
"0",
"test"
};
List vertices = new List();
foreach (System.Windows.Point p in feature.GetPoints())
{
vertices.Add(new PointF((float)p.X, (float)p.Y));
}
shpWriter.AddRecord(vertices.ToArray(), vertices.Count, fieldData);
}
shpWriter.Close();
The .shx .dbf and .shp will be created but you have to create a .prj for the shape yourself. I used a normal TextWriter for it:
TextWriter tw = new StreamWriter(shpFilePath + "/" + shapeName + ".prj");
tw.WriteLine("PROJCS[\"RD_New\", GEOGCS[\"GCS_Amersfoort\", DATUM[\"D_Amersfoort\", SPHEROID[\"Bessel_1841\", 6377397.155, 299.1528128]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"Degree\", 0.0174532925199433]], PROJECTION[\"Double_Stereographic\"], PARAMETER[\"False_Easting\", 155000.0], PARAMETER[\"False_Northing\", 463000.0], PARAMETER[\"Central_Meridian\", 5.38763888888889], PARAMETER[\"Scale_Factor\", 0.9999079], PARAMETER[\"Latitude_Of_Origin\", 52.15616055555555], UNIT[\"Meter\", 1.0]]");
tw.Close();
Be aware that a shapefile can only contain 1 geometry type within a Shapefile.
This is perfect for my project and really easy to use.
Here an example of my drawing and the exported shapefile in ArcMap (My drawing created with the Surface Simulator looks awfull but hey you get the idea)


We’ve been trying to get NASA World Wind to run on the Microsoft Surface, the first problem we ran into was that we didn’t got the current stable version (1.4) to run on the surface so we tried out the