code: def edit(
      ctx,
      input,
      bidx,
      nodata,
      unset_nodata,
      crs,
      unset_crs,
      transform,
      units,
      description,
      tags,
      allmd,
      like,
      colorinterp,
  ):
      """Edit a dataset's metadata: coordinate reference system, affine
      transformation matrix, nodata value, and tags.
  
      The coordinate reference system may be either a PROJ.4 or EPSG:nnnn
      string,
  
        --crs 'EPSG:4326'
  
      or a JSON text-encoded PROJ.4 object.
  
        --crs '{"proj": "utm", "zone": 18, ...}'
  
      Transforms are JSON-encoded Affine objects like:
  
        --transform '[300.038, 0.0, 101985.0, 0.0, -300.042, 2826915.0]'
  
      Prior to Rasterio 1.0 GDAL geotransforms were supported for --transform,
      but are no longer supported.
  
      Metadata items may also be read from an existing dataset using a
      combination of the --like option with at least one of --all,
      `--crs like`, `--nodata like`, and `--transform like`.
  
        rio edit-info example.tif --like template.tif --all
  
      To get just the transform from the template:
  
        rio edit-info example.tif --like template.tif --transform like
  
      """
      # If '--all' is given before '--like' on the commandline then 'allmd'
      # is the string 'like'.  This is caused by '--like' not having an
      # opportunity to populate metadata before '--all' is evaluated.
      if allmd == "like":
          allmd = ctx.obj["like"]
  
      with ctx.obj["env"], rasterio.open(input, "r+") as dst:
          if allmd:
              nodata = allmd["nodata"]
              crs = allmd["crs"]
              transform = allmd["transform"]
              tags = allmd["tags"]
              colorinterp = allmd["colorinterp"]
  
          if unset_nodata and nodata is not None:
              raise click.BadParameter(
                  "--unset-nodata and --nodata cannot be used together."
              )
  
          if unset_crs and crs:
              raise click.BadParameter(
                  "--unset-crs and --crs cannot be used together."
              )
  
          if unset_nodata:
              # Setting nodata to None will raise NotImplementedError
              # if GDALDeleteRasterNoDataValue() isn't present in the
              # GDAL library.
              try:
                  dst.nodata = None
              except NotImplementedError as exc:  # pragma: no cover
                  raise click.ClickException(str(exc))
  
          elif nodata is not None:
              dtype = dst.dtypes[0]
              if nodata is not None and not in_dtype_range(
                  nodata, dtype
              ):
                  raise click.BadParameter(
                      "outside the range of the file's data type (%s)."
                      % dtype,
                      param=nodata,
                      param_hint="nodata",
                  )
              dst.nodata = nodata
  
          if unset_crs:
              dst.crs = None
          elif crs:
              dst.crs = crs
  
          if transform:
              dst.transform = transform
  
          if tags:
              dst.update_tags(**tags)
  
          if units:
              dst.set_band_unit(bidx, units)
  
          if description:
              dst.set_band_description(bidx, description)
  
          if colorinterp:
              if like and len(colorinterp) != dst.count:
                  raise click.ClickException(
                      "When using '--like' for color interpretation the "
                      "template and target images must have the same number "
                      "of bands.  Found {template} color interpretations for "
                      "template image and {target} bands in target "
                      "image.".format(
                          template=len(colorinterp), target=dst.count
                      )
                  )
              try:
                  dst.colorinterp = colorinterp
              except ValueError as e:
                  raise click.ClickException(str(e))
  
      # Post check - ensure that crs was unset properly
      if unset_crs:
          with ctx.obj["env"], rasterio.open(input, "r") as src:
              if src.crs:
                  warnings.warn(
                      "CRS was not unset. Availability of his functionality "
                      "differs depending on GDAL version and driver"
                  )
  
file_path: rasterio/rasterio/rio/edit_info.py
imports: import json
  import warnings
  import click
  import rasterio
  import rasterio.crs
  from rasterio.crs import CRS
  from rasterio.dtypes import in_dtype_range
  from rasterio.enums import ColorInterp
  from rasterio.errors import CRSError
  from rasterio.rio import options
  from rasterio.transform import guard_transform
label_desc: Use image node_id 6 for calling a global function with example usage: edit(ctx, input, bidx, nodata, unset_nodata, crs, unset_crs, transform, units, description, tags, allmd, like, colorinterp) without return types