class_docstr: A class representing a GeoJSON object.
class_docstr_tok: ["A","class","representing","a","GeoJSON","object","."]
docstr: Encode a GeoJSON dict into an GeoJSON object.
  Assumes the caller knows that the dict should satisfy a GeoJSON type.
  
  :param cls: Dict containing the elements to be encoded into a GeoJSON
  object.
  :type cls: dict
  :param ob: GeoJSON object into which to encode the dict provided in
  `cls`.
  :type ob: GeoJSON
  :param default: A default instance to append the content of the dict
  to if none is provided.
  :type default: GeoJSON
  :param strict: Raise error if unable to coerce particular keys or
  attributes to a valid GeoJSON structure.
  :type strict: bool
  :return: A GeoJSON object with the dict's elements as its constituents.
  :rtype: GeoJSON
  :raises TypeError: If the input dict contains items that are not valid
  GeoJSON types.
  :raises UnicodeEncodeError: If the input dict contains items of a type
  that contain non-ASCII characters.
  :raises AttributeError: If the input dict contains items that are not
  valid GeoJSON types.
docstr_tok: ["Encode","a","GeoJSON","dict","into","an","GeoJSON","object",".","Assumes","the","caller","knows","that","the","dict","should","satisfy","a","GeoJSON","type",".",":","param","cls",":","Dict","containing","the","elements","to","be","encoded","into","a","GeoJSON","object",".",":","type","cls",":","dict",":","param","ob",":","GeoJSON","object","into","which","to","encode","the","dict","provided","in","`","cls","`",".",":","type","ob",":","GeoJSON",":","param","default",":","A","default","instance","to","append","the","content","of","the","dict","to","if","none","is","provided",".",":","type","default",":","GeoJSON",":","param","strict",":","Raise","error","if","unable","to","coerce","particular","keys","or","attributes","to","a","valid","GeoJSON","structure",".",":","type","strict",":","bool",":","return",":","A","GeoJSON","object","with","the","dict","'s","elements","as","its","constituents",".",":","rtype",":","GeoJSON",":","raises","TypeError",":","If","the","input","dict","contains","items","that","are","not","valid","GeoJSON","types",".",":","raises","UnicodeEncodeError",":","If","the","input","dict","contains","items","of","a","type","that","contain","non-ASCII","characters",".",":","raises","AttributeError",":","If","the","input","dict","contains","items","that","are","not","valid","GeoJSON","types","."]
code: def to_instance(cls, ob, default=None, strict=False):
      """Encode a GeoJSON dict into an GeoJSON object.
      Assumes the caller knows that the dict should satisfy a GeoJSON type.
  
      :param cls: Dict containing the elements to be encoded into a GeoJSON
      object.
      :type cls: dict
      :param ob: GeoJSON object into which to encode the dict provided in
      `cls`.
      :type ob: GeoJSON
      :param default: A default instance to append the content of the dict
      to if none is provided.
      :type default: GeoJSON
      :param strict: Raise error if unable to coerce particular keys or
      attributes to a valid GeoJSON structure.
      :type strict: bool
      :return: A GeoJSON object with the dict's elements as its constituents.
      :rtype: GeoJSON
      :raises TypeError: If the input dict contains items that are not valid
      GeoJSON types.
      :raises UnicodeEncodeError: If the input dict contains items of a type
      that contain non-ASCII characters.
      :raises AttributeError: If the input dict contains items that are not
      valid GeoJSON types.
      """
      if ob is None and default is not None:
          instance = default()
      elif isinstance(ob, GeoJSON):
          instance = ob
      else:
          mapping = to_mapping(ob)
          d = {}
          for k in mapping:
              d[k] = mapping[k]
          try:
              type_ = d.pop("type")
              try:
                  type_ = str(type_)
              except UnicodeEncodeError:
                  # If the type contains non-ascii characters, we can assume
                  # it's not a valid GeoJSON type
                  raise AttributeError(
                      "{0} is not a GeoJSON type"
                  ).format(type_)
              geojson_factory = getattr(geojson.factory, type_)
              instance = geojson_factory(**d)
          except (AttributeError, KeyError) as invalid:
              if strict:
                  msg = "Cannot coerce %r into a valid GeoJSON structure: %s"
                  msg %= (ob, invalid)
                  raise ValueError(msg)
              instance = ob
      return instance
  
file_path: geojson/geojson/base.py
imports: import geojson
  from geojson.mapping import to_mapping
label_desc: Use image node_id 7 for calling the GeoJSON obj's underlying member method code with example usage: obj.to_instance(cls, ob, default, strict) and returns: instance