public List<string> ShptoWkt(string path)
{
List<string> list = new List<string>();
string wkt = "";
OSGeo.OGR.Ogr.RegisterAll();
OSGeo.OGR.Driver dr = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
if (dr == null)
{
return list;
}
OSGeo.OGR.DataSource ds = dr.Open(path, 0);
int layerCount = ds.GetLayerCount();
OSGeo.OGR.Layer layer = ds.GetLayerByIndex(0);
//投影信息
OSGeo.OSR.SpatialReference coord = layer.GetSpatialRef();
string coordString;
coord.ExportToWkt(out coordString);
OSGeo.OGR.Feature feat;
//string contentString = "";
//读取shp文件
while ((feat = layer.GetNextFeature()) != null)
{
OSGeo.OGR.Geometry geometry = feat.GetGeometryRef();
OSGeo.OGR.wkbGeometryType goetype = geometry.GetGeometryType();
geometry.ExportToWkt(out wkt);
list.Add(wkt);
}
return list;
}