Skip to content

Instantly share code, notes, and snippets.

@airbreather
Last active October 25, 2017 13:04
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 airbreather/0937a51d8949e467e1bc61be7c970e3f to your computer and use it in GitHub Desktop.
Save airbreather/0937a51d8949e467e1bc61be7c970e3f to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel;
using GeoAPI;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
const string ShapefilePath = "foo.shp"; // change me. obviously.
NetTopologySuiteBootstrapper.Bootstrap();
var rd = new ShapefileDataReader(ShapefilePath, GeometryFactory.Default);
foreach (ICustomTypeDescriptor dsc in rd)
{
int i = 0;
foreach (PropertyDescriptor val in dsc.GetProperties())
{
Console.Write("[{0}]: ", i++);
object finalValue = val.GetValue(dsc);
switch (finalValue)
{
case IGeometry geom:
Console.Write("(geom)");
break;
default:
Console.Write("{0} = {1}", val.Name, finalValue);
break;
}
Console.Write("; ");
}
Console.WriteLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment