Package: mapactionpy-arcmap
MapChefMaster branchAdds geospatial data to an ArcMap MXD file based on a recipe from a cookbook configuration file and a product name.PrerequisitesPython v2.7 and ArcPy v10.6.1C:\Python27\ArcGIS10.6\python.exeArcMap MapAction templates and Crash Move Folder as setout herehttps://github.com/mapaction/default-crash-move-folderFor the Crash Move Folder to have been populated by the Data Scramble process.InstallingTo install the lastest stable release via PyPi:pip install mapactionpy-controller
pip install mapactionpy-arcmapTo install a specific version for testing see the relevant commandline from here:https://pypi.org/project/mapactionpy-arcmap/#historyOptional Installation of ArcMap ESRI AddinIn additiona to the commandline the MapChef tool can also optionally be driven from an ArcMap Addin. To install this:If required, uninstall any previous version of the ArcMap Esri Add-In.Reinstall ArcMap Esri Add-In using file here:https://drive.google.com/drive/u/0/folders/1qzR6UvqA_RjxK9D2U9_AXi3EW4cXnuP7Restart ArcMap and ensure the 'Map Generation Tool' is available within the MapAction toolbar.To run the 'Map Generation Tool' the standardised Crash Move Folder must be in place, see:https://github.com/mapaction/default-crash-move-folder/blob/master/20YYiso3nnIntegration with MapAction ToolbarIn order to integrate thisMapActionPy_ArcMapmodule with the MapAction Toolbar, the following steps need to be carried out:Configuration FilesCookbook FileThemapCookbook.jsonfile is a static configuration file which contains "recipes" for each map product, e.g.:{ 
   "recipes":[ 
      { 
         "mapnumber":"MA001",
         "category":"Reference",
         "product":"Country Overview with Admin 1 Boundaries & P-Codes",
         "export": true,
         "layers":[ 
            "mainmap-s0-pt-settlements",
            "mainmap-s0-py-surroundingcountries",
            "mainmap-s0-ln-admin1",
            "mainmap-s0-ln-coastline",
            "mainmap-s0-py-feather",
            "mainmap-s0-py-surroundingcountries",
            "mainmap-s0-py-admin1",
            "mainmap-s0-py-sea",
            "locationmap-s0-ln-admin1",
            "locationmap-s0-ln-affectedcountry",
            "locationmap-s0-ln-coastline",
            "locationmap-s0-py-surroundingcountries"
         ]
      },
...
    }
  ]
}The layer names in the "layers" array MUST correlate to layer files (.lyr) in the specified layer directory:[GIS/3_Mapping/31_Resources/312_Layer_files] (https://github.com/mapaction/default-crash-move-folder/tree/master/20YYiso3nn/GIS/3_Mapping/31_Resources/312_Layer_files)layerConfig FileThe Layer Config file (layerProperties.json) is a static file which defines how to add a particular layer."MapFrame": "Main Map",
      "LayerName": "mainmap-s0-pt-settlements",
      "RegExp": "^[a-z]{3}_stle_stl_pt_(.*?)_(.*?)_([phm][phm])(.*?).shp$",
      "DefinitionQuery": "place IN ('national_capital', 'city', 'capital')",
      "Display": true,
      "AddToLegend": true,
      "LabelClasses": [
        {
          "className": "National Capital",
          "expression": "[name]",
          "SQLQuery": "(\"place\" = 'national_capital')"
        },
        {
          "className": "Admin 1 Capital",
          "expression": "[name]",
          "SQLQuery": "(\"place\" = 'city')"
        }
      ]
    },Fields#FieldDescription1MapFrameName of the Map Frame that the layer is to be added to2LayerNameName of the Layer.  This must correlate with the names of the layers in thelayersfield in themapCookbook.jsonfile.3RegExpRegular Expression.  Used when selecting files to display4DefinitionQueryDefinition Query5AddToLegendIncludes this layer in the legend if set to true6DisplayShows if set to true7LabelClassesDetails for displaying labelsExecutionKey#IconMeaning1:heavy_check_mark:Must always be supplied2:zap:If not supplied, this parameter can be inferred if thecmf_description.jsonand theevent_description.jsonfiles are in he root of the Crash Move Folder.Parameters#FieldMandatoryDescription1--cookbook:zap:Path to the cookbookmapCookbook.jsonfile.2--layerConfig:zap:Path to thelayerProperties.jsonfile.3--cmf:heavy_check_mark:Path to the Crash Move Folder root.4--template:zap:Path to theMXDfile.5--product:heavy_check_mark:Name of product (must correlate with a product in the cookbook file).6--country:zap:Name of country.Example 1For a specified MXD using the--templateparameter:--cookbook "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\316_Automation\mapCookbook.json" \
   --layerConfig "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\316_Automation\layerProperties.json" \
   --cmf "D:\MapAction\2019-06-25 - Automation - El Salvador" \
   --template "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\32_MXD_Templates\arcgis_10_2\MapAction\01 Reference mapping\arcgis_10_2_ma000_reference_landscape_bottom_DEV.mxd" \
   --layerDirectory "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\312_Layer_files" \
   --product "Country Overview with Admin 1 Boundaries & P-Codes" \
   --country "El Salvador"ResultThisCountry Overviewmap was generated:Example 2--cookbook "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\316_Automation\mapCookbook.json" \
   --layerConfig "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\316_Automation\layerProperties.json" \
   --cmf "D:\MapAction\2019-06-25 - Automation - El Salvador" \
   --layerDirectory "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\312_Layer_files" \
   --product "Country Overview with Admin 1 Boundaries & P-Codes" \
   --country "El Salvador"If an MXD is not supplied with the--templateparameter as above, then the tool will decide the orientation of the map (landscape or portrait) and it will take a copy of the appropriate MXD from:<crash move folder>\GIS\3_Mapping\32_MXD_Templates\arcgis_10_6\Using themapnumberfrom themapCookbook.jsonfile, the Automation Tool will create a copy of the MXD under the following directory:<crash move folder>\GIS\3_Mapping\33_MXD_Maps\<map number>For example:D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\33_MXD_Maps\MA001The MXD name will be <map number>_<product name>.mxd... (but with any characters removed that upset Windows Explorer)For example:MA001_country-overview-with-admin-1-boundaries-p-codes.mxdExample 3C:\Python27\ArcGIS10.6\python.exe -m mapactionpy_arcmap.arcmap_runner \
   --cmf "D:\MapAction\2019-06-25 - Automation - El Salvador" \
   --product "Country Overview with Admin 1 Boundaries & P-Codes"In this example, the following parameters were not provided:--cookbook
--layerConfig
--layerDirectory
--countryThe values for these parameters were inferred from theevent_description.jsonand thecmf_description.jsonfiles.These files were provided at the root of the Crash Move Folder, i.e. the directory supplied by the--cmfparameter.AuthorSteve Hurst-https://github.com/mapaction/mapactionpy_arcmap