[gdal-dev] ogr2ogr and extents

Frank Warmerdam warmerdam at pobox.com
Wed Apr 15 10:59:03 EDT 2009


Vincent Honnet wrote:
> Hi,
> 
> I am very new in this mailing list and I hope I don't ask for something 
> already posted. If so, please excuse me.
> I look a bit in the archive for my problem but found nothing relevant.
> 
> I want to tile my shapefiles with fixed extents in order to raster them 
> to tif files and then to do some treatments in Photoshop.
> I use for that a script with ogr2ogr used with the option -spat
> The problem is that some shapfiles have a only small part of the extent 
> filled with data. The result is that the extent of the croped shapefile 
> is a bounding box of those data and not the extent I set with -spat:
> for exemple with "-spat -136 -9 -127 0" I can get a shapefiles with 
> -130.5 -8.2 -130.2 -8.1
> 
> Is there any possibility to get a shapefile with the extent I gave in 
> the command line ?

Vincent,

The OGR shape driver does not currently support setting the extent value
in the shapefile header except as an aggregate of the features that get
written.  If this is particularly important to you, you should be able
to write a small C program to reset the extents in the headers.

Alternatively you could write a feature to each tile that is essentially
the founding rectangle of the extents you want, and then afterwards delete
this feature though there might be some negative side effects to this that
I can't immediately forsee.

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    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list