[gdal-dev] Need suggestion on clipping vectors in batch

Margherita Di Leo diregola at gmail.com
Thu Oct 6 05:47:05 PDT 2016


Dear Even,

On Wed, Oct 5, 2016 at 8:53 PM, Even Rouault <even.rouault at spatialys.com>
wrote:

>
>
> Tiny Python script with GDAL 2.1 :
>
> from osgeo import gdal
> src_ds = gdal.OpenEx('your.shp')
> lyr = src_ds.GetLayer(0)
> minx, maxx, miny, maxy = lyr.GetExtent()
> # Note the different order of bounds between previous and next line
> gdal.VectorTranslate("out.shp", src_ds, \
>  spatFilter=(minx + DX,miny +DY,maxx-DX, maxy-DX))
>
>
>
> Many thanks!
I'm having some headache because I have gdal 1.11 installed system-wide,
coming from package, so I installed gdal 2.2 in local in $HOME/opt/gdal
(=$GDAL_INSTALL_DIR)
in my terminal I run:

$ export PATH=$GDAL_INSTALL_DIR/bin:$PATH
$ export LD_LIBRARY_PATH=$GDAL_INSTALL_DIR/lib:$LD_LIBRARY_PATH
$ export GDAL_DATA=$GDAL_INSTALL_DIR/share/gdal
$ gdalinfo --version
GDAL 2.2.0dev, released 2016/99/99

$ python
[...]
>>> from osgeo import gdal
>>> gdal.VersionInfo()
'1110400'

Also, in sys.path() the $GDAL_INSTALL_DIR is listed correctly... I'm at a
dead end :-/


-- 
Margherita Di Leo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20161006/f974001e/attachment.html>


More information about the gdal-dev mailing list