class_docstr: A BytesIO-like object, backed by an in-memory file.
  
  This allows formatted files to be read and written without I/O.
  
  A MemoryFile created with initial bytes becomes immutable. A
  MemoryFile created without initial bytes may be written to using
  either file-like or dataset interfaces.
  
  Examples
  --------
  
  A GeoTIFF can be loaded in memory and accessed using the GeoTIFF
  format driver
  
  >>> with open('tests/data/RGB.byte.tif', 'rb') as f, MemoryFile(f) as memfile:
  ...     with memfile.open() as src:
  ...         pprint.pprint(src.profile)
  ...
  {'count': 3,
   'crs': CRS({'init': 'epsg:32618'}),
   'driver': 'GTiff',
   'dtype': 'uint8',
   'height': 718,
   'interleave': 'pixel',
   'nodata': 0.0,
   'tiled': False,
   'transform': Affine(300.0379266750948, 0.0, 101985.0,
         0.0, -300.041782729805, 2826915.0),
   'width': 791}
docstr: Open the file and return a Rasterio dataset object.
  
  If data has already been written, the file is opened in 'r'
  mode. Otherwise, the file is opened in 'w' mode.
  
  Parameters
  ----------
  Note well that there is no `path` parameter: a `MemoryFile`
  contains a single dataset and there is no need to specify a
  path.
  
  Other parameters are optional and have the same semantics as the
  parameters of `rasterio.open()`.
docstr_tok: ["Open","the","file","and","return","a","Rasterio","dataset","object",".","If","data","has","already","been","written",",","the","file","is","opened","in","'","r'","mode",".","Otherwise",",","the","file","is","opened","in","'","w","'","mode",".","Parameters","--","--","--","--","--","Note","well","that","there","is","no","`","path","`","parameter",":","a","`","MemoryFile","`","contains","a","single","dataset","and","there","is","no","need","to","specify","a","path",".","Other","parameters","are","optional","and","have","the","same","semantics","as","the","parameters","of","`","rasterio.open","(",")","`","."]
code: def open(
      self,
      driver=None,
      width=None,
      height=None,
      count=None,
      crs=None,
      transform=None,
      dtype=None,
      nodata=None,
      sharing=False,
      **kwargs,
  ):
      """Open the file and return a Rasterio dataset object.
  
      If data has already been written, the file is opened in 'r'
      mode. Otherwise, the file is opened in 'w' mode.
  
      Parameters
      ----------
      Note well that there is no `path` parameter: a `MemoryFile`
      contains a single dataset and there is no need to specify a
      path.
  
      Other parameters are optional and have the same semantics as the
      parameters of `rasterio.open()`.
      """
      mempath = _UnparsedPath(self.name)
  
      if self.closed:
          raise ValueError("I/O operation on closed file.")
      if len(self) > 0:
          log.debug("VSI path: {}".format(mempath.path))
          rd = DatasetReader(
              mempath, driver=driver, sharing=sharing, **kwargs
          )
      else:
          writer = get_writer_for_driver(driver)
          rd = writer(
              mempath,
              "w+",
              driver=driver,
              width=width,
              height=height,
              count=count,
              crs=crs,
              transform=transform,
              dtype=dtype,
              nodata=nodata,
              sharing=sharing,
              **kwargs,
          )
  
      # Push the new dataset's context exit onto the MemoryFile's ExitStack.
      # This ensures that when this MemoryFile is closed, any derived dataset
      # is also closed automatically.
      self._env.push(rd)
      return rd
  
imports: import logging
  import warnings
  from rasterio._base import get_dataset_driver, driver_can_create, driver_can_create_copy
  from rasterio._io import DatasetReaderBase, DatasetWriterBase, BufferedDatasetWriterBase, MemoryFileBase
  from rasterio.windows import WindowMethodsMixin
  from rasterio.env import ensure_env
  from rasterio.errors import RasterioDeprecationWarning
  from rasterio.transform import TransformMethodsMixin
  from rasterio._path import _UnparsedPath
label_desc: Use image node_id 2 for calling the MemoryFile obj's underlying member method code with example usage: obj.open(driver, width, height, count, crs, transform, dtype, nodata, sharing) and returns: rd