Skip to content

Instantly share code, notes, and snippets.

@bertt
Created October 1, 2015 08:52
Show Gist options
  • Save bertt/eb945b20661f26498477 to your computer and use it in GitHub Desktop.
Save bertt/eb945b20661f26498477 to your computer and use it in GitHub Desktop.
System.Data.Spatial code sample for .NET 4.5/4.6
Add a reference to System.Data.Entity
var geom1 = DbGeometry.PolygonFromText("POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2))",4326);
var geom2 = DbGeometry.LineFromText("LINESTRING(3 4,10 50,20 25)", 4326);
var geom3 = geom2.Buffer(1);
if (geom1.Overlaps(geom3)){
var geom4 = geom1.Difference(geom3);
Console.WriteLine("geom4: " + geom4.AsText());
Console.WriteLine("area: " + geom4.Area);
}
Console.WriteLine(geom1.Intersects(geom2));
Console.WriteLine(geom3.AsText());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment