[Qgis-user] Re: Resetting the extent of a shapefile

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Tue Jan 31 06:57:50 PST 2012


magerlin <MAP at ...> writes:

> 
> I have deleted large geographical parts of a shape file because I only needed
> a very little part of it.
> 
> But using "Zoom to layer extent" still zoom to the extent of the original
> shape file.
> 
> I have tried to re-save the file using save-as, specifying CRS etc. but no
> change.
> 
> In "Layer properties, Metadata" I can read:
> 
> /Extents:
> In layer spatial reference system units : xMin,yMin 622219.27,1154061.75 :
> xMax,yMax 643120.73,1204120.54/
> 
> Where are these data stored and how do I update it?

Hi,

>From http://gdal.org/ogr/drv_shapefile.html 

Spatial extent

Shapefiles store the layer spatial extent in the .SHP file. The layer spatial
extent is automatically updated when inserting a new feature in a shapefile.
However when updating an existing feature, if its previous shape was touching
the bounding box of the layer extent but the updated shape does not touch the
new extent, the computed extent will not be correct. It is then necessary to
force a recomputation by invoking the SQL 'RECOMPUTE EXTENT ON <tablename>' via
the datasource ExecuteSQL() method. The same applies for the deletion of a shape.

Note: RECOMPUTE EXTENT ON is available in OGR >= 1.9.0.

Thus RECOMPUTE EXTENT ON should help, or then saving the modified data into new
shapefile and renaming that back afterwards.

-Jukka Rahkonen-




More information about the Qgis-user mailing list