I'm using NetTopologySuite
to read a shapefile like below code:
private FeatureDataTable GetFeatureTableFromShapefile(string shapeFilePath)
{
GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
FeatureDataSet ds;
using (var sf = new ShapeFile(shapeFilePath) {Encoding = Encoding.Default})
{
sf.Open();
var ext = sf.GetExtents();
ds = new FeatureDataSet();
sf.ExecuteIntersectionQuery(ext, ds);
}
return ds.Tables[0];
}
Now I want to merge all features and create only one feature from them.
Please note that I'm trying to create one feature and not something like multipolygon like below image:
For above image, i used this code, but it's not what i want, because there still a red line between to features that i tried to merge:
var entities = new List<DbGeometry>(){ d1.Geom, d2.Geom};
DbGeometry allBoundaries = null;
for (var i = 0; i < entities.Count; i++)
{
if (i == 0) allBoundaries = entities[i].Boundary;
else allBoundaries = allBoundaries.Union(entities[i].Boundary);
}
So is there any way to accomplish this?