[Gdal-dev] inner join

Frank Warmerdam fwarmerdam at gmail.com
Fri Apr 29 09:35:45 EDT 2005


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.  
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). 

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