[gdal-dev] C#: Simple geometry loading

Casper Børgesen (CABO) CABO at NIRAS.DK
Sun Oct 21 05:02:45 PDT 2012


Hi!

I have this very simple problem which I don't understand. I am loading a shape file (multipolygon) and copying the geometry into a new structure:

            OSGeo.OGR.Geometry geometries = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbMultiPolygon);

            OSGeo.OGR.DataSource dataSource = OSGeo.OGR.Ogr.Open(filename, 0);
            OSGeo.OGR.Layer layer = dataSource.GetLayerByIndex(0);
            OSGeo.OGR.Feature currentFeature = null;
            layer.ResetReading();
            while ((currentFeature = layer.GetNextFeature()) != null)
            {
                string wkt = string.Empty;
                currentFeature.GetGeometryRef().ExportToWkt(out wkt); --> MULTIPOLYGON (((476587.2 6100012.8, .... ,533324.8 6190163.2)))
                geometries.AddGeometry(currentFeature.GetGeometryRef());
                string wkt2 = string.Empty;
                geometries.ExportToWkt(out wkt2); --> MULTIPOLYGON EMPTY
            }
            dataSource.Dispose();

Am I doing something completely wrong here?

I just want all of the geometry in the input file put into the variable geometries for later use.

The input data is a rather large data set and before I try to strip it down, I just want to know if my approach is wrong or if I can expect this to be working.

GDAL/OGR version: 1.9.2, C# bindings from Tamas daily builds.

Regards Casper





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20121021/1324c849/attachment.html>


More information about the gdal-dev mailing list