[Gdal-dev] Change EXTENT of a shapefile

Frank Warmerdam warmerdam at pobox.com
Mon Apr 21 09:46:29 EDT 2008


shortyII wrote:
> Hi,
> i am trying to change the EXTENT parameters of a shapefile with ogr2ogr:
> 
> ogr2ogr -update -spat 3500000 5300000 3540000 5400000 rastervorlage.shp
> rastervorlage.shp
> FAILED: Layer rastervorlage already exists, and -append not specified.
>         Consider using -append, or -overwrite.
> ERROR 1: Terminating translation prematurely after failed
> translation of layer rastervorlage
> 
> but it doesn't work. (-append and -overwrite also don't work)
> Is it in principal possible to change the extent and how can i do it?
> Thank you!

Stefan,

You cannot subset the features within a shapefile with ogr2ogr, you need
to copy the subset to a new shapefile.

So instead use:

  ogr2ogr -spat 3500000 5300000 3540000 5400000 out.shp rastervorlage.shp

Once complete you can delete the original, and rename the new to the
original if you want.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list