def filter(self, *args, **kwds): """Returns an iterator over records, but filtered by a test for spatial intersection with the provided ``bbox``, a (minx, miny, maxx, maxy) tuple or a geometry ``mask``. Positional arguments ``stop`` or ``start, stop[, step]`` allows iteration to skip over items or stop at a specific item. """ if self.closed: raise ValueError("I/O operation on closed collection") elif self.mode != 'r': raise IOError("collection not open for reading") if args: s = slice(*args) start = s.start stop = s.stop step = s.step else: start = stop = step = None bbox = kwds.get('bbox') mask = kwds.get('mask') if bbox and mask: raise ValueError("mask and bbox can not be set together") self.iterator = Iterator(self, start, stop, step, bbox, mask) return self.iterator
def filter(self, *args, **kwds): """Returns an iterator over records, but filtered by a test for spatial intersection with the provided ``bbox``, a (minx, miny, maxx, maxy) tuple or a geometry ``mask``. An attribute filter can be set using an SQL ``where`` clause, which uses the `OGR SQL dialect <https://gdal.org/user/ogr_sql_dialect.html#where>`__. Positional arguments ``stop`` or ``start, stop[, step]`` allows iteration to skip over items or stop at a specific item. """ if self.closed: raise ValueError("I/O operation on closed collection") elif self.mode != 'r': raise IOError("collection not open for reading") if args: s = slice(*args) start = s.start stop = s.stop step = s.step else: start = stop = step = None bbox = kwds.get('bbox') mask = kwds.get('mask') if bbox and mask: raise ValueError("mask and bbox can not be set together") where = kwds.get('where') self.iterator = Iterator(self, start, stop, step, bbox, mask, where) return self.iterator
def filter(self, bbox=None): """Returns an iterator over GeoJSON-like mappings of features, but filtered by a test for spatial intersection with the provided ``bbox``, a (minx, miny, maxx, maxy) tuple.""" if self.mode != 'r': raise IOError("Collection is not open for reading") return Iterator(self, bbox)
def filter(self, bbox=None): """Returns an iterator over records, but filtered by a test for spatial intersection with the provided ``bbox``, a (minx, miny, maxx, maxy) tuple.""" if self.closed: raise ValueError("I/O operation on closed collection") elif self.mode != 'r': raise IOError("collection not open for reading") self.iterator = Iterator(self, bbox) return self.iterator
def filter(self, bbox=None, query=None): """Returns an iterator over records, but filtered either by a test for spatial intersection with the provided ``bbox``, a (minx, miny, maxx, maxy) tuple and/or by an attribute filter, provided by ``query`` (e.g. "population > 1000000").""" if self.closed: raise ValueError("Collection is not open for reading") elif self.mode != 'r': raise IOError("Collection is not open for reading") if self.iterator is None: self.iterator = Iterator(self, bbox, query) return self.iterator
def __iter__(self): """Returns an iterator over GeoJSON-like mappings of features""" if self.mode != 'r': raise IOError("Collection is not open for reading") return Iterator(self)