There might be situations where you have geospatial data in CSV format, and you want to read that data from within your .NET applications. For such cases, this article will teach you how to read vector layer features, points, and geometries from CSV files using C#.
- C# API for Reading Vector Layer Features, Points, and Geometries from CSV Files
- Read Features from CSV Files using C#
- Reading Points from CSV Files using C#
- Read Geometries from CSV Files using C#
C# API for Reading Vector Layer Features, Points, and Geometries from CSV Files
Aspose.GIS for .NET API allows you to work with geospatial data stored in various file formats. It provides you the ability to render maps and create, read, and convert geographic data without additional software. Furthermore, the API allows you to read vector layer features, points, and geometries from CSV files. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.GIS
Read Features from CSV Files using C#
The following are the steps to read features from a vector layer in a CSV file.
- Load the CSV file using the Drivers.Csv.OpenLayer(string path) method.
- Loop through the attributes and features in the layer and print their values.
The following sample code shows how to read features from a vector layer in a CSV file using C#.
Reading Points from CSV Files using C#
The following are the steps to read points from a vector layer in a CSV file.
- Load the CSV file using the Drivers.Csv.OpenLayer(string path, CsvOptions options) method.
- Set the ColumnX, ColumnY, ColumnZ, and ColumnM properties of the CsvOptions object.
- Loop through the features in the layer and print the points.
The following sample code shows how to read points from a vector layer in a CSV file using C#.
Read Geometries from CSV Files using C#
The following are the steps to read geometries from the vector layer in a CSV file.
- Load the CSV file using the Drivers.Csv.OpenLayer(string path, CsvOptions options) method.
- Set the ColumnWkt property of the CsvOptions object.
- Loop through the features in the layer and print the geometries to the console.
The following sample code shows how to read geometries from a vector layer in a CSV file using C#.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to read features from CSV files using C#. Furthermore, you have seen how to read points and geometries from CSV files using Aspose.GIS for .NET API. It is a powerful API that provides many additional features for working with geospatial data. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us at our free support forum.