Skip to main content

Used to drive ArcMap

Project description

MapChef

Master branch Build Status Coverage Status

Adds geospatial data to an ArcMap MXD file based on a recipe from a cookbook configuration file and a product name.

Prerequisites

Python and ArcPy

C:\Python27\ArcGIS10.6\python.exe

Packaging

python setup.py bdist_wheel

Installing

python -m pip install jsonpickle

To install for development purposes: Clone the github repo then from the root of your local clone:

python -m pip install --user -e .

To install for use non-development purposes: Clone the github repo then from the root of your local clone:

python -m pip install .

todo: [] enable installation via pypi.

Configuration Files

Cookbook File

The mapCookbook.json file is a static configuration file which contains "recipes" for each map product.

This example cookbook only contains a single product: Country Overview.

{
  "recipes": [
    {
      "product": "Country Overview",
      "classification": "Core",
      "layers": [
        "mainmap-s0-pt-settlements",
        "mainmap-s0-pt-airports",
        "mainmap-s0-pt-seaports",
        "mainmap-s0-py-feather",
        "Borders - Admin 0",
        "mainmap-s1-ln-admin1",
        "mainmap-s0-ln-roads",
        "mainmap-s0-ln-rail",
        "mainmap-s0-py-waterbodies",
        "mainmap-s0-ln-rivers",
        "mainmap-s0-py-admin1",
        "mainmap-s0-py-affectedcountry",
        "mainmap-s0-py-surroundingcountries",
        "mainmap-s0-py-sea",
        "mainmap-s0-ras-dem",
        "mainmap-s0-ras-hillshade",
        "Location Map - Admin 0 Polygon"
      ]
    }
  ]
}

The layer names in the "layers" array MUST correlate to layer files (.lyr) in the specified layer directory.

layerConfig File

The 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": "Yes",
      "LabelClasses": [
        {
          "className": "National Capital",
          "expression": "[name]",
          "SQLQuery": "(\"place\" = 'national_capital')"
        },
        {
          "className": "Admin 1 Capital",
          "expression": "[name]",
          "SQLQuery": "(\"place\" = 'city')"
        }
      ]
    },

Fields

# Field Description
1 MapFrame Name of the Map Frame that the layer is to be added to
2 LayerName Name of the Layer. This must correlate with the layerFile.Name field in the mapCookbook.json file.
3 RegExp Regular Expression. Used when selecting files to display
4 DefinitionQuery Definition Query
5 Display Shows if set to 'Yes'
6 LabelClasses Details for displaying labels

Execution

Parameters

# Field Description
1 ```--cookbook`` Path to the cookbook mapCookbook.json file.
2 --layerConfig Path to the layerProperties.json file.
3 --cmf Path to the Crash Move Folder root.
4 --template Path to the MXD file.
5 --product Name of product (must correlate with a product in the cookbook file).
6 --country Name of country.

Example

C:\Python27\ArcGIS10.6\python.exe main.py \
   --cookbook "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\31_Resources\31A_Automation\mapCookbook.json" \ 
   --layerConfig "C:\Users\steve\Source\Repos\mapactionpy_arcmap\poc\MapChef\Config\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" \
   --product "Country Overview" \
   --country "El Salvador"

Result

This Country Overview map was generated:

alt text

Integration with MapAction Toolbar

In order to integrate this MapActionPy_ArcMap module with the MapAction Toolbar, the following steps need to be carried out:

:information_source: The "Automation" add-in is in development in the automation branch at: https://github.com/mapaction/mapaction-toolbox/tree/automation):

  1. All layer .lyr files should be made available under the crash move folder at the following location: \GIS\3_Mapping\31_Resources\312_Layer_files
  2. Layer properties file layerProperties.json copied to new directory under the crash move folder at the following location: \GIS\3_Mapping\31_Resources\31A_Automation
  3. Map cookbook file mapCookbook.json copied to directory under the crash move folder at the following location: \GIS\3_Mapping\31_Resources\31A_Automation

Authors

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mapactionpy_arcmap-0.2.dev69.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file mapactionpy_arcmap-0.2.dev69.tar.gz.

File metadata

  • Download URL: mapactionpy_arcmap-0.2.dev69.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/2.7.15

File hashes

Hashes for mapactionpy_arcmap-0.2.dev69.tar.gz
Algorithm Hash digest
SHA256 7e5d6e21c79e68b0f2f03b48d68e0b6f93f702f6c322cf78352a78698f407ac4
MD5 f20e37220c539b7c5755f0a66c45f7e6
BLAKE2b-256 22b7cede57763ab90466338199bf6cbcedf318dd6938bc72d8ee4ba6d55a705a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page