Make Geometric Shapes using a C# GIS Library

This guide is for the .NET developers who are seeking help in drawing geometric shapes programmatically. These shapes include polygons, points, lines, curved lines, and more. So, let’s aim to develop a solution that automates the whole process of drawing shapes. Therefore, for this purpose, we will opt for Aspose.GIS for .NET which is a powerful C# GIS library. Moreover, it is lightweight and offers a bunch of features for programmatic manipulation and the creation of various types of shapes. Now, we will head over to the installation and then the implementation of how to make geometric shapes in C#.

C# GIS Library Installation

Aspose.GIS for .NET offers robust installation, download the DLL file or you can execute the following command in NuGet Package Manager. That’s it.

C# gis library installation

Curve Lines Drawing in .NET - Code Sample

The following steps and the code sample demonstrate how to draw curved lines in a Shapefile.

  • Create the layer and open it to add new features by calling the Create method.
  • Invoke the ConstructFeature method to create a new feature.
  • Initialize a new instance of the MultiCurve class.
  • Invoke the Add method to add a line string, circular string, and compound curve to the collection.
  • Set the Geometry of the feature.
  • Invoke the Add method to add a feature to the layer.
curve lines drawing in .NET

Similarly, you can draw straight lines by following the code sample mentioned below:

  • Create an instance of the LineString class.
  • Add points to the ends of the line by calling the AddPoint method.
lines drawing in dotnet

Create Polygon Programmatically - Code Sample

Next, this section shows the creation of a polygon in C# using Aspose.GIS for .NET.

  • Instantiate an object of the Polygon class.
  • Create an instance of the LinearRing class.
  • Add points to the end of the lines by calling the AddPoint method.
  • Set the exterior ring by setting the value of ExteriorRing property.
Create Polygon Programmatically

Generate Geometric Points - Code Sample

This C# GIS library offers methods to create geometric points programmatically:

  • Create an instance of the MultiPoint class and call the Add method to create points.
Generate Geometric Points

Make Geometric Shapes in C# - Get a Free License

You can get a free temporary license to try this C# GIS library without evaluation limitations.

Summing up

You have learned how to make geometric shapes in C# using Aspose.GIS for .NET. In addition, we implemented functionalities such as creating polygons, lines, curved lines, and points. So, these are a few provisions we explored, there is a huge stack of other cool features offered by this C# GIS library. We encourage you to visit our documentation, API refs, and GitHub repo for further exploration.

Feel Free to Reach Out

You can let us know about your questions or queries on our forum.

See Also