1

The Django GDAL documentation for coord_dim says:

coord_dim
Returns or sets the coordinate dimension of this geometry. For example, the value would be 2 for two-dimensional geometries.

But how do I actually set the dimension? I'm working with three dimensional data, and trying to convert it to two dimensional data:

    ds = DataSource(options['filename'])
    for layer in ds:
        for i in layer:
            print i.geom.coord_dim
            i.geom.coord_dim = 2
            print i.geom.coord_dim

This doesn't produce an error, but outputs 3 twice, and doesn't seem to change the coordinates at all when I print those.

How do I use coord_dim to set the number of coordinates?

The underlying thing I'm trying to achieve is to transform three-dimensional data to two-dimensional data.

1

I can't test this, but as a educated guess:

from django.contrib.gis.gdal import OGRGeometry

ds = DataSource(options['filename'])
    for layer in ds:
        for i in layer:
            ogrgeom = OGRGeometry(i.geom)  # Make an OGRGeom object from the string representation
            ogrgeom.z = None  # This is now a 2 dimensional geometry object with no Z coordinate
            # Do other things
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.