[Gdal-dev] inner join

Richard Greenwood richard.greenwood at gmail.com
Fri Apr 29 14:37:27 EDT 2005


On 4/29/05, Frank Warmerdam <fwarmerdam at gmail.com> wrote:
> On 4/28/05, Richard Greenwood <richard.greenwood at gmail.com> wrote:
> > I am trying to create a destination shape file that is a sub-set of a
> > source shape file, based on a join to a dbf.
> >
> > Poly.shp is the source shape file. Listing.dbf has the list of records
> > that I want from poly.shp.
> >
> > In pseudocode  I want something like:
> >    Select * from poly where id in (select id from listing)
> > Or:
> >    Select * from poly where poly.id = listing.id
> 
> Richard,
> 
> I'm afraid to say the half-assed SQL JOIIN implementation in OGR
> isn't up to doing this.  If you have some sort of extra column in listing.dbf
> then you could likely do your join and then do another ogr2ogr that
> would filter out all records where the extra column is NULL.

That's a great solution! Thank you.

> Alternatively, you could write a python script to do the operation,
> basically reading the listing.dbf, and then reading all features from
> the source dataset, and only copying those in the listing from the
> second (stored in a hash for instance).

My python skills are pretty thin right now, but after Sean & Howard's
workshop this June I'm sure I'll be up to the task.

As always, thank you very much for your help.

Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com



More information about the Gdal-dev mailing list