class_docstr: A file-like interface to features of a vector dataset
  
  Python text file objects are iterators over lines of a file. Fiona
  Collections are similar iterators (not lists!) over features
  represented as GeoJSON-like mappings.
class_docstr_tok: ["A","file-like","interface","to","features","of","a","vector","dataset","Python","text","file","objects","are","iterators","over","lines","of","a","file",".","Fiona","Collections","are","similar","iterators","(","not","lists","!",")","over","features","represented","as","GeoJSON-like","mappings","."]
docstr: The required ``path`` is the absolute or relative path to
  a file, such as '/data/test_uk.shp'. In ``mode`` 'r', data can
  be read only. In ``mode`` 'a', data can be appended to a file.
  In ``mode`` 'w', data overwrites the existing contents of
  a file.
  
  In ``mode`` 'w', an OGR ``driver`` name and a ``schema`` are
  required. A Proj4 ``crs`` string is recommended. If both ``crs``
  and ``crs_wkt`` keyword arguments are passed, the latter will
  trump the former.
  
  In 'w' mode, kwargs will be mapped to OGR layer creation
  options.
docstr_tok: ["The","required","``","path","``","is","the","absolute","or","relative","path","to","a","file",",","such","as","'\/data\/test_uk.shp","'",".","In","``","mode","``","'","r","'",",","data","can","be","read","only",".","In","``","mode","``","'","a","'",",","data","can","be","appended","to","a","file",".","In","``","mode","``","'","w","'",",","data","overwrites","the","existing","contents","of","a","file",".","In","``","mode","``","'","w","'",",","an","OGR","``","driver","``","name","and","a","``","schema","``","are","required",".","A","Proj4","``","crs","``","string","is","recommended",".","If","both","``","crs","``","and","``","crs_wkt","``","keyword","arguments","are","passed",",","the","latter","will","trump","the","former",".","In","'","w","'","mode",",","kwargs","will","be","mapped","to","OGR","layer","creation","options","."]
code: def __init__(
      self,
      path,
      mode="r",
      driver=None,
      schema=None,
      crs=None,
      encoding=None,
      layer=None,
      vsi=None,
      archive=None,
      enabled_drivers=None,
      crs_wkt=None,
      ignore_fields=None,
      ignore_geometry=False,
      include_fields=None,
      wkt_version=None,
      allow_unsupported_drivers=False,
      **kwargs,
  ):
      """The required ``path`` is the absolute or relative path to
      a file, such as '/data/test_uk.shp'. In ``mode`` 'r', data can
      be read only. In ``mode`` 'a', data can be appended to a file.
      In ``mode`` 'w', data overwrites the existing contents of
      a file.
  
      In ``mode`` 'w', an OGR ``driver`` name and a ``schema`` are
      required. A Proj4 ``crs`` string is recommended. If both ``crs``
      and ``crs_wkt`` keyword arguments are passed, the latter will
      trump the former.
  
      In 'w' mode, kwargs will be mapped to OGR layer creation
      options.
  
      """
      self._closed = True
  
      if not isinstance(path, (str, Path)):
          raise TypeError(f"invalid path: {path!r}")
      if not isinstance(mode, str) or mode not in ("r", "w", "a"):
          raise TypeError(f"invalid mode: {mode!r}")
      if driver and not isinstance(driver, str):
          raise TypeError(f"invalid driver: {driver!r}")
      if schema and not hasattr(schema, "get"):
          raise TypeError("invalid schema: %r" % schema)
  
      # Rasterio's CRS is compatible with Fiona. This class
      # constructor only requires that the crs value have a to_wkt()
      # method.
      if (
          crs
          and not isinstance(crs, compat.DICT_TYPES + (str, CRS))
          and not (hasattr(crs, "to_wkt") and callable(crs.to_wkt))
      ):
          raise TypeError("invalid crs: %r" % crs)
  
      if crs_wkt and not isinstance(crs_wkt, str):
          raise TypeError(f"invalid crs_wkt: {crs_wkt!r}")
      if encoding and not isinstance(encoding, str):
          raise TypeError(f"invalid encoding: {encoding!r}")
      if layer and not isinstance(layer, (str, int)):
          raise TypeError(f"invalid name: {layer!r}")
      if vsi:
          if not isinstance(vsi, str) or not vfs.valid_vsi(vsi):
              raise TypeError(f"invalid vsi: {vsi!r}")
      if archive and not isinstance(archive, str):
          raise TypeError(f"invalid archive: {archive!r}")
      if ignore_fields is not None and include_fields is not None:
          raise ValueError(
              "Cannot specify both 'ignore_fields' and 'include_fields'"
          )
  
      if mode == "w" and driver is None:
          driver = driver_from_extension(path)
  
      # Check GDAL version against drivers
      if (
          driver in driver_mode_mingdal[mode]
          and get_gdal_version_tuple()
          < driver_mode_mingdal[mode][driver]
      ):
          min_gdal_version = ".".join(
              list(map(str, driver_mode_mingdal[mode][driver]))
          )
  
          raise DriverError(
              f"{driver} driver requires at least GDAL {min_gdal_version} "
              f"for mode '{mode}', "
              f"Fiona was compiled against: {get_gdal_release_name()}"
          )
  
      self.session = None
      self.iterator = None
      self._len = 0
      self._bounds = None
      self._driver = None
      self._schema = None
      self._crs = None
      self._crs_wkt = None
      self.enabled_drivers = enabled_drivers
      self.include_fields = include_fields
      self.ignore_fields = ignore_fields
      self.ignore_geometry = bool(ignore_geometry)
      self._allow_unsupported_drivers = allow_unsupported_drivers
      self._env = None
      self._closed = True
  
      # Check GDAL version against drivers
      if (
          driver in driver_mode_mingdal[mode]
          and get_gdal_version_tuple()
          < driver_mode_mingdal[mode][driver]
      ):
          min_gdal_version = ".".join(
              list(map(str, driver_mode_mingdal[mode][driver]))
          )
  
          raise DriverError(
              f"{driver} driver requires at least GDAL {min_gdal_version} "
              f"for mode '{mode}', "
              f"Fiona was compiled against: {get_gdal_release_name()}"
          )
  
      if vsi:
          self.path = vfs.vsi_path(path, vsi, archive)
          path = parse_path(self.path)
      else:
          path = parse_path(path)
          self.path = vsi_path(path)
  
      if mode == "w":
          if layer and not isinstance(layer, str):
              raise ValueError(
                  "in 'w' mode, layer names must be strings"
              )
          if driver == "GeoJSON":
              if layer is not None:
                  raise ValueError(
                      "the GeoJSON format does not have layers"
                  )
              self.name = "OgrGeoJSON"
          # TODO: raise ValueError as above for other single-layer formats.
          else:
              self.name = layer or os.path.basename(
                  os.path.splitext(path.path)[0]
              )
      else:
          if layer in (0, None):
              self.name = 0
          else:
              self.name = layer or os.path.basename(
                  os.path.splitext(path)[0]
              )
  
      self.mode = mode
  
      if self.mode == "w":
          if driver == "Shapefile":
              driver = "ESRI Shapefile"
          if not driver:
              raise DriverError("no driver")
          if not allow_unsupported_drivers:
              if driver not in supported_drivers:
                  raise DriverError(f"unsupported driver: {driver!r}")
              if self.mode not in supported_drivers[driver]:
                  raise DriverError(f"unsupported mode: {self.mode!r}")
          self._driver = driver
  
          if not schema:
              raise SchemaError("no schema")
          if "properties" in schema:
              # Make properties as a dict built-in
              this_schema = schema.copy()
              this_schema["properties"] = dict(schema["properties"])
              schema = this_schema
          else:
              schema["properties"] = {}
          if "geometry" not in schema:
              schema["geometry"] = None
          self._schema = schema
  
          self._check_schema_driver_support()
  
          if crs_wkt or crs:
              self._crs_wkt = CRS.from_user_input(
                  crs_wkt or crs
              ).to_wkt(version=wkt_version)
  
      self._driver = driver
      kwargs.update(encoding=encoding)
      self.encoding = encoding
  
      try:
          if self.mode == "r":
              self.session = Session()
              self.session.start(self, **kwargs)
          elif self.mode in ("a", "w"):
              self.session = WritingSession()
              self.session.start(self, **kwargs)
      except OSError:
          self.session = None
          raise
  
      if self.session is not None:
          self.guard_driver_mode()
  
      if self.mode in ("a", "w"):
          self._valid_geom_types = _get_valid_geom_types(
              self.schema, self.driver
          )
  
      self.field_skip_log_filter = FieldSkipLogFilter()
      self._env = ExitStack()
      self._closed = False
  
imports: from contextlib import ExitStack
  import logging
  import os
  import warnings
  from fiona import compat, vfs
  from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
  from fiona.ogrext import Session, WritingSession
  from fiona.ogrext import buffer_to_virtual_file, remove_virtual_file, GEOMETRY_TYPES
  from fiona.errors import DriverError, DriverSupportError, GDALVersionError, SchemaError, UnsupportedGeometryTypeError, UnsupportedOperation
  from fiona.logutils import FieldSkipLogFilter
  from fiona.crs import CRS
  from fiona._env import get_gdal_release_name, get_gdal_version_tuple
  from fiona.env import env_ctx_if_needed
  from fiona.errors import FionaDeprecationWarning
  from fiona.drvsupport import driver_from_extension, supported_drivers, driver_mode_mingdal, _driver_converts_field_type_silently_to_str, _driver_supports_field
  from fiona.path import Path, vsi_path, parse_path
label_desc: Use image node_id 1 to create a new Collection object  with example: obj = Collection(path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, include_fields, wkt_version, allow_unsupported_drivers)