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

Even Rouault even.rouault at spatialys.com
Thu Oct 6 06:25:32 PDT 2016


Le jeudi 06 octobre 2016 14:47:05, Margherita Di Leo a écrit :
> 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 :-/

Try:

export PYTHONPATH=$GDAL_INSTALL_DIR/lib/python2.7/site-packages

( adapt the path to the python version you use)


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list