[gdal-dev] ogr - layer extent weirdness after geometry update

Simon Lyngby Kokkendorff silyko at gmail.com
Thu Apr 7 15:54:43 EDT 2011


Hi List,

  I have observed a puzzling behaviour of the reported extent of an ogr
layer after geometries of features have been modified, with the file opened
in update mode. I use gdal 1.7 via the pyhton bindings, open a dataset with
ogr.Open(fname,update=True), then loop through layers and features and
modify geometries like:
geom=feature.GetGeometryRef(), new_geom=some_modification(geom),
feature.SetGeometry(new_geom), layer.SetFeature(feature). However, ogr (and
Qgis, which uses ogr for that I suppose) reports the new layer extent as,
the "minimal bounding box" of the new and old extents. So somehow, the
extent before geometry modification is still stored somewhere in the
dataset. The same observations also hold for a dataset which is modified by
hand using the editing tools in Qgis! Consider the following ogrinfo output
from a file with one layer, containing one point:
INFO: Open of `qgis_test.shp'
      using driver `ESRI Shapefile' successful.

Layer name: qgis_test
Geometry: Point
Feature Count: 1
Extent: (0.077586, 0.577586) - (10.670690, 31.805172)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_1984",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
test: String (80.0)
OGRFeature(qgis_test):0
  test (String) = nothing
  POINT (10.670689655172414 31.805172413793112)

Even though the point clearly lies at (10.67,31.80) the previous position is
still included in the extent. Is this a bug or is there some reasoning
behind this behaviour?

Best Regards,
Simon. National Survey and Cadastre of Denmark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110407/c5cb0ae6/attachment.html


More information about the gdal-dev mailing list