fiona SQL filter

Loïc Dutrieux

Hi everyone,

I'm trying to do some attribute filtering of a fiona feature collection using the where clause but I cannot find out the right syntax. Here's what I've tried.

Thanks for any help,
Kind regards,

import string
import tempfile, os

import fiona
from import from_epsg
from shapely.geometry import Point, mapping

# Generate test data and save to tmp geopackage
gpkg = os.path.join(tempfile.gettempdir(), 'fiona_sql_test.gpkg')
sc = [Point(1,2), Point(3,4), Point(5,6)]
fc = [{'geometry': mapping(s),
'properties': {'letter': string.ascii_lowercase[idx]}}
for idx,s in enumerate(sc)]
schema = {'geometry': 'Point',
'properties': {'letter': 'str'}}
with, 'w', driver='GPKG', schema=schema, crs=from_epsg(4326),
layer='test') as dst:

# Filter using OGR SQL dialect
with, layer='test') as src:
fc = src.filter(where='"letter" = "a"')
for feat in fc:

Join to automatically receive all group messages.