code: def _add_lonlat_coords(data_arr: xr.DataArray) -> xr.DataArray:
      """Add 'longitude' and 'latitude' coordinates to DataArray."""
      data_arr = data_arr.copy()
      area = data_arr.attrs["area"]
      ignore_dims = {
          dim: 0 for dim in data_arr.dims if dim not in ["x", "y"]
      }
      chunks = getattr(data_arr.isel(**ignore_dims), "chunks", None)
      lons, lats = area.get_lonlats(chunks=chunks)
      data_arr["longitude"] = xr.DataArray(
          lons,
          dims=["y", "x"],
          attrs={
              "name": "longitude",
              "standard_name": "longitude",
              "units": "degrees_east",
          },
          name="longitude",
      )
      data_arr["latitude"] = xr.DataArray(
          lats,
          dims=["y", "x"],
          attrs={
              "name": "latitude",
              "standard_name": "latitude",
              "units": "degrees_north",
          },
          name="latitude",
      )
      return data_arr
  
imports: import logging
  import xarray
  from packaging.version import Version
  from pyresample.geometry import AreaDefinition, SwathDefinition
label_desc: Use image node_id 1 for calling a global function with example usage: _add_lonlat_coords(data_arr) and returns: data_arr