Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active November 5, 2021 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/504b09424d4da605ce3e21f1021cf957 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/504b09424d4da605ce3e21f1021cf957 to your computer and use it in GitHub Desktop.
Read Vector Layer Features, Points, and Geometries from CSV Files
using (var layer = Drivers.Csv.OpenLayer(dataDir + "sample.csv"))
{
// Print attributes
foreach (var attribute in layer.Attributes)
{
Console.Write($"'{attribute.Name}' ");
}
Console.WriteLine();
// Print records
foreach (var feature in layer)
{
var dump = feature.GetValuesDump();
foreach (var item in dump)
{
Console.Write($"'{item}' ");
}
Console.WriteLine();
}
}
using (var layer = Drivers.Csv.OpenLayer(dataDir + "geometries.csv",
new CsvOptions()
{
ColumnWkt = "geom_data"
}))
{
// Print geometry in wkt format
foreach (var feature in layer)
{
Console.Write($"'{feature.Geometry.AsText()}: ");
Console.WriteLine();
}
}
using (var layer = Drivers.Csv.OpenLayer(dataDir + "geometries.csv",
new CsvOptions()
{
ColumnX = "x",
ColumnY = "y",
ColumnZ = "z",
ColumnM = "m"
}))
{
// Print geometry in wkt format
foreach (var feature in layer)
{
Console.Write($"'{feature.Geometry.AsText()}: ");
Console.WriteLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment