如何使用 dotspatial 从 ASP.NET 中的 shapefile 获取内环(孔)?

How to get inner ring(hole) from shapefile in ASP.NET using dotspatial?

我正在搜索脚本以使用点空间从 shapefile 中的多边形获取内环。下面是我从 shapefile 中获取所有坐标(忽略 outer/inner 环)的脚本。

string shapeFilePath = @"\example.shp";
shapeFilePath = location + shapeFilePath;
Shapefile indexMapFile = Shapefile.OpenFile(shapeFilePath);
indexMapFile.Reproject(KnownCoordinateSystems.Geographic.Australia.GeocentricDatumofAustralia1994);

for (int i = 0; i < indexMapFile.DataTable.Rows.Count; i++)
{

    IFeature feature = indexMapFile.Features.ElementAt(i);

    var arr = feature.Coordinates.ToArray();

    foreach (var det in arr)
    {
        DotSpatial.Topology.Coordinate det_cor = det;
        string X = det_cor.X.ToString();
        string Y = det_cor.Y.ToString();
    }
}

我找到了答案,这是我的代码,如何从多边形中获取内环

string shapeFilePath = @"\example.shp";
shapeFilePath = location + shapeFilePath;
Shapefile indexMapFile = Shapefile.OpenFile(shapeFilePath);
indexMapFile.Reproject(KnownCoordinateSystems.Geographic.Australia.GeocentricDatumofAustralia1994);

for (int i = 0; i < indexMapFile.DataTable.Rows.Count; i++)
{

    IFeature feature = indexMapFile.Features.ElementAt(i);
    IPolygon bp = feature.GetBasicGeometryN(0) as IPolygon;
    var all_polygon = bp.GetGeometryN(0);//include outer and inner ring, see this link -> 
    var outer_ring = bp.Shell.GetGeometryN(0);
    int idx_hole = 0;
    foreach (var hole in bp.Holes)
    {
        //get inner ring/hole from polygon
        Response.Write(bp.GetInteriorRingN(idx_hole));
        idx_hole++;
    }
}