amaptor.Map

class amaptor.Map(project, map_object)[source]

Corresponds to an ArcMap Data Frame or an ArcGIS Pro Map

add_layer(add_layer, add_position='AUTO_ARRANGE')[source]
Straight replication of addLayer API in arcpy.mp and arcpy.mapping. Adds a layer to a specified position in the table of contents.
Parameters:
  • add_layer – The layer to add to the map
  • add_position – The position to add the layer into. The default is AUTO_ARRANGE, and available options are the same as those available on addLayer.
Returns:

None

export_pdf(out_path, layout='ALL', **kwargs)[source]
See documentation for _export for description of behavior in each version. kwargs that apply to exporting to PDF in ArcMap and ArcGIS Pro apply here.
Parameters:
  • out_path – The full path to export the document to. Will be modified in the case of layout=”ALL”. New generated paths will be returned by the function as a list.
  • layout – PRO only, safely ignored in ArcMap. The mp.Layout or amaptor.Layout object to export, or the keyword “ALL”
  • **kwargs

    accepts the set of parameters that works for both arcmap and arcgis pro. resolution, image_quality, image_compression, embed_fonts, layers_attributes, georef_info, jpeg_compression_quality. In the future, this may be reengineered to translate parameters with common goals but different names

Returns:

export_png(out_path, resolution=300, layout='ALL')[source]
See documentation for _export for description of behavior in each version. The specific option here is only the resolution to export at.
Parameters:
  • out_path – The full path to export the document to. Will be modified in the case of layout=”ALL”. New generated paths will be returned by the function as a list.
  • resolution – the resolution to export the map at
  • layout – PRO only, safely ignored in ArcMap. The mp.Layout or amaptor.Layout object to export, or the keyword “ALL”
Returns:

find_layer(name=None, path=None, find_all=False)[source]
Given the name OR Path of a layer in the map, returns the layer object. If both are provided, returns based on path. If multiple layers with the same name/path exist, returns the first one, unless find_all is True - then it returns a list with all instances. Automatically converted to work with new Layer object because self.layers uses them
Parameters:
  • name
  • path
  • find_all
Returns:

arcpy.Layer object

insert_feature_class_with_symbology(feature_class, layer_file, layer_name=None, near_name=None, near_path=None, insert_position='BEFORE')[source]
Given a path to a feature calss, and a path to a layer file, creates a layer with layer file symbology and inserts it using insert_layer_by_name_or_path’s approach
Parameters:
  • feature_class
  • layer_file
  • layer_name
  • near_name
  • near_path
  • insert_position
Returns:

insert_layer(reference_layer, insert_layer_or_layerfile, insert_position='BEFORE')[source]
Inserts a layer to a specific position in the table of contents, based on a reference layer.
Parameters:
  • reference_layer – The arcpy Layer instance to use as the reference layer
  • insert_layer_or_layerfile – The arcpy Layer instance to insert
  • insert_position – the position relative to the reference layer to insert the new layer. Default is “BEFORE” (above). options correspond to those available on insertLayer in arcpy.mapping and arcpy.mp
Returns:

None

insert_layer_by_name_or_path(insert_layer_or_layer_file, near_name=None, near_path=None, insert_position='BEFORE')[source]
Not a standard arcpy.mapping or arcpy.mp function - given a name or data source path of a layer, finds it in the layers, and inserts it. Only provide either near_name or near_path. If both are provided, near_path will be used because it’s more specifci :param insert_layer_or_layer_file: :param near_name: :param near_path: :param insert_position:
Returns:None
list_layers()[source]
Returns the list of layers in the map or data frame. Also available as map.layers
Returns:
name
replace_text(text, replacement)[source]

Given a string and a replacement value, finds all instances of that text in text elements and titles, and replaces those instances with the new value. Useful for creating your own variables like {species} or {field_id} in map templates.

Similar to the project-level replace_text, but behaves slightly differently. In ArcMap, replaces all occurrences in the current map document. In Pro, searches all layouts linked to the current layout and replaces the string in any text element in those layouts.

Parameters:
  • text
  • replacement
Returns:

set_extent(extent_object, set_frame='ALL', add_buffer=True, buffer_factor=0.05)[source]
Sets map frames to a provided extent object. In ArcMap, just sets the data frame’s extent. In Pro, it has many potential behaviors. If set_frame == “ALL” it sets all map frames linked to this map to this extent (default behavior) and sets the default camera for this map so that future map frames will use the same extent. If set_frame is an arcpy.mp MapFrame object instance, then it only sets the extent on that map frame.
Parameters:
  • extent_object – an arcpy.Extent object. It will be reprojected to the spatial reference of the map frame or data frame automatically.
  • set_frame – ignored in arcmap, behavior described in main method description.
  • add_buffer – adds an empty space of 5% of the distance across the feature class around the provided extent
  • buffer_factor – if add_buffer is True, then this factor controls how much space to add around the layer (default=.05)
Returns:

None

to_package(output_file, **kwargs)[source]
Though it’s not normally a mapping method, packaging concepts need translation between the two versions, so we’ve included to_package for maps and projects. In ArcGIS Pro, project.to_package will create a Project Package and map.to_package will create a map package. In ArcMap, both will create a map package. Calling to_package on the map will pass through all kwargs to map packaging because the signatures are the same between ArcMap and ArcGIS Pro. Sending kwargs to project.to_package will only send to project package since they differ.
Parameters:
  • output_file
  • kwargs
Returns:

zoom_to_layer(layer, set_frame='ALL', add_buffer=True, buffer_factor=0.05)[source]
Given a name of a layer as a string or a layer object, zooms the map extent to that layer WARNING: In Pro, see the parameter information for set_layout on the set_extent method for a description of how this option behaves. Since maps don’t correspond 1:1 to layouts, in some cases multiple layouts will be changed.
Parameters:
  • layer – can be a string name of a layer, or a layer object
  • set_layout – PRO ONLY, but ignored in ArcMap, so can be safe to use. This parameter controls which map frames are changed by the Zoom to Layer. By default, all linked map frames are updated. If an arcpy.mp.MapFrame instance or an amaptor.MapFrame instance is provided, it zooms only that map frame to the layer.
  • add_buffer – adds an empty space of 5% of the distance across the feature class around the provided extent
  • buffer_factor – if add_buffer is True, then this factor controls how much space to add around the layer (default=.05)
Returns:

None