首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用点空间重新投影的Shapefile与原始Shapefile不同

使用点空间重新投影的Shapefile与原始Shapefile不同
EN

Stack Overflow用户
提问于 2018-12-27 20:24:36
回答 1查看 173关注 0票数 0

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

代码语言:javascript
复制
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与原始的不同?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-03-07 03:01:08

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

代码语言:javascript
复制
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
                }
            }

        }

    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53945057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档