【问题标题】:Shapefile that is reprojected using dotspatial is different from the original one使用点空间重新投影的形状文件与原始文件不同
【发布时间】:2018-12-27 12:24:35
【问题描述】:

我有一个带有 EPSG:32749 的 shapefile,它将被插入到 Oracle 数据库并显示在 geoserver 中。在此之前,我想使用点空间库将我的 shapefile 重新投影到 ESPG:4326,这是我的代码

var EXTRACTED_NAME = Server.MapPath("~/upload/shp/example/");
string shapeFilePath = @"\example.shp";
shapeFilePath = EXTRACTED_NAME + shapeFilePath;
Shapefile indexMapFile = Shapefile.OpenFile(shapeFilePath);
indexMapFile.Reproject(KnownCoordinateSystems.Geographic.World.WGS1984);

但是当我在geoserver中预览时,我的shapefile是这样显示的,当原来的shapefile是这样的时候

我的问题是,为什么重新投影到 EPSG 4326 的 shapefile 与原始文件不同?

谢谢

【问题讨论】:

  • 你告诉geoserver投影已经改变了吗?
  • 是的,当我在 geoserver 中创建图层时,我用 epsg:4326 填充了 SRS
  • 哦,我的错,发生这种情况是因为我认为多边形中没有内环。以及如何使用点空间从多边形中获取内环?
  • 不知道我害怕,你可以使用 ogr2ogr 来修复它

标签: asp.net geoserver dotspatial


【解决方案1】:

这有点晚了,但您应该能够从几何图形中访问内环。您可能需要将 IGeometry 转换为 IPolygon 以专门处理内环,而不仅仅是 getGeometryN。下面的代码还没有经过测试,但至少应该能让你找到正确的方向。

Shapefile file = Shapefile.OpenFile(@"D:\Data\Counties\Counties.shp");
foreach(Feature f in file.Features){
    if(f.Geometry is IPolygon){
        IPolygon p = (IPolygon)f.Geometry;
        Debug.WriteLine("Feature " + f.Fid + "\n");
        foreach(ILineString innerRing in p.InteriorRings){
            // Do stuff with your innerRing
            Debug.WriteLine("Ring length : " + innerRing.Length);
        }
    }
    if (f.Geometry is IMultiPolygon)
    {
        IMultiPolygon multi = (IMultiPolygon)f.Geometry;
        for (int i = 0; i < multi.NumGeometries; i++)
        {
            IGeometry g = multi.GetGeometryN(i);
            if (g is IPolygon)
            {
                IPolygon p = (IPolygon)g;
                foreach (ILineString innerRing in p.InteriorRings)
                {
                    // Do stuff with your innerRing
                }
            }

        }

    }

}

【讨论】:

    猜你喜欢
    • 2020-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-06
    相关资源
    最近更新 更多