Geometry Constructors

Point Geometry

Create Point

Creating a geospatial point using the API is simple and easy as shown in the following code sample.

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
Point point = new Point(40.7128, -74.006);

Create MultiPoint

Aspose.GIS for .NET provides the facility to represent a collection of points as a single MultiPoint class. It can contain one or more Points defined by lat-long information of each Point.

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
MultiPoint multipoint = new MultiPoint();
multipoint.Add(new Point(1, 2));
multipoint.Add(new Point(3, 4));

Line String Geometry

You can create a Line String specifying Point Geometries.

Create a Line String

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
LineString line = new LineString();
line.AddPoint(78.65, -32.65);
line.AddPoint(-98.65, 12.65);

Create a MultiLine String

A MultiLine string is a collection of Line Strings that itself are built from Point geometries. 

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
LineString firstLine = new LineString();
firstLine.AddPoint(7.5, -3.5);
firstLine.AddPoint(-9.6, 12.6);
LineString secondLine = new LineString();
secondLine.AddPoint(8.5, -2.6);
secondLine.AddPoint(-8.6, 1.5);
MultiLineString multiLineString = new MultiLineString();
multiLineString.Add(firstLine);
multiLineString.Add(secondLine);

Polygon Geometry

A Polygon is a collection of Point geometries which is defined by Points in the form LinearRing.

Create Polygon

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
Polygon polygon = new Polygon();
LinearRing ring = new LinearRing();
ring.AddPoint(50.02, 36.22);
ring.AddPoint(49.99, 36.26);
ring.AddPoint(49.97, 36.23);
ring.AddPoint(49.98, 36.17);
ring.AddPoint(50.02, 36.22);
polygon.ExteriorRing = ring;

Create MultiPolygon

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
LinearRing firstRing = new LinearRing();
firstRing.AddPoint(8.5, -2.5);
firstRing.AddPoint(-8.5, 2.5);
firstRing.AddPoint(8.5, -2.5);
Polygon firstPolygon = new Polygon(firstRing);
LinearRing secondRing = new LinearRing();
secondRing.AddPoint(7.6, -3.6);
secondRing.AddPoint(-9.6, 1.5);
secondRing.AddPoint(7.6, -3.6);
Polygon secondPolygon = new Polygon(secondRing);
MultiPolygon multiPolygon = new MultiPolygon();
multiPolygon.Add(firstPolygon);
multiPolygon.Add(secondPolygon);

Create Polygon with Hole

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
Polygon polygon = new Polygon();
LinearRing ring = new LinearRing();
ring.AddPoint(50.02, 36.22);
ring.AddPoint(49.99, 36.26);
ring.AddPoint(49.97, 36.23);
ring.AddPoint(49.98, 36.17);
ring.AddPoint(50.02, 36.22);
LinearRing hole = new LinearRing();
hole.AddPoint(50.00, 36.22);
hole.AddPoint(49.99, 36.20);
hole.AddPoint(49.98, 36.23);
hole.AddPoint(50.00, 36.24);
hole.AddPoint(50.00, 36.22);
polygon.ExteriorRing = ring;
polygon.AddInteriorRing(hole);

Create Geometry Collection

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
Point point = new Point(40.7128, -74.006);
LineString line = new LineString();
line.AddPoint(78.65, -32.65);
line.AddPoint(-98.65, 12.65);
GeometryCollection geometryCollection = new GeometryCollection();
geometryCollection.Add(point);
geometryCollection.Add(line);