code: def create_analysis_layer(analysis_extent, crs, name):
      
      fields = [
          create_field_from_definition(analysis_name_field)
      ]
      analysis_layer = create_memory_layer(
          'analysis', QgsWkbTypes.PolygonGeometry, crs, fields)
  
      analysis_layer.startEditing()
  
      feature = QgsFeature()
      # noinspection PyCallByClass,PyArgumentList,PyTypeChecker
      feature.setGeometry(analysis_extent)
      feature.setAttributes([name])
      analysis_layer.addFeature(feature)
      analysis_layer.commitChanges()
  
      # Generate analysis keywords
      analysis_layer.keywords['layer_purpose'] = (
          layer_purpose_analysis_impacted['key'])
      analysis_layer.keywords['title'] = 'analysis'
      analysis_layer.keywords[inasafe_keyword_version_key] = (
          inasafe_keyword_version)
      analysis_layer.keywords['inasafe_fields'] = {
          analysis_name_field['key']: analysis_name_field['field_name']
      }
  
      return analysis_layer
docs: Create the analysis layer.
  
      :param analysis_extent: The analysis extent.
      :type analysis_extent: QgsGeometry
  
      :param crs: The CRS to use.
      :type crs: QgsCoordinateReferenceSystem
  
      :param name: The name of the analysis.
      :type name: basestring
  
      :returns: A polygon layer with exposure's crs.
      :rtype: QgsVectorLayer