[gdal-dev] How open a subset dataset with python
Even Rouault
even.rouault at mines-paris.org
Thu Jun 26 14:30:42 PDT 2014
Le jeudi 19 juin 2014 22:05:13, Andrea Peri a écrit :
> Hi, resolved the quest.
>
> the command is
> layer = ds.ExecuteSQL(sqlString,None,"SQLITE")
Andrea,
You could also directly open with ogr.Open(file) (no need to explicitely
request the driver).
And if the driver is indeed SQLite, you don't need to precise the "SQLITE"
dialect since by default for RDBMS based drivers, the SQL is evaluated by the
RDMBS engine. But that will not hurt specifying it.
To avoid memory leaks (in case you would call it many times in a loop), on a
layer returned with ExecuteSQL(), remember to call ds.ResultResultSet(layer).
Best regards,
Even
>
> Andrea.
>
> 2014-06-19 18:10 GMT+02:00 Andrea Peri <aperi2007 at gmail.com>:
> > Hi,
> >
> > I'm study-ing the option to use the python with gdal:
> > This are my first step on the python world.
> >
> > I use this code:
> >
> > driver = ogr.GetDriverByName('SQLite')
> > ds = driver.Open(file)
> > layer = ds.GetLayerByName(dataset)
> >
> > But I like to open instead of a full "dataset" a subset of it as
> > usually do in ogr2ogr
> > using the two parameters:
> >
> > -sql statement and the parameter "-dialect SQLITE"
> >
> > is this possible in python ?
> >
> > Thx to everyone,
> >
> > --
> > -----------------
> > Andrea Peri
> > . . . . . . . . .
> > qwerty àèìòù
> > -----------------
--
Geospatial professional services
http://even.rouault.free.fr/services.html
More information about the gdal-dev
mailing list