Used to drive ArcMap
Project description
MapChef
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
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": [
"Settlements - Places",
"Provinces",
"Cartography - Feather",
"Transport - Airports",
"Transport - Seaports",
"Elevation - Coastline",
"Borders - Admin 0",
"Borders - Admin 1",
"Transport - Rail",
"Transport - Roads",
"Physical - Lakes",
"Physical - Rivers",
"Admin - Ad 1 Polygon",
"Admin 0 - Affected Country",
"Elevation - DEM",
"Physical - Sea",
"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",
"LayerGroup": "Elevation",
"LayerName": "Physical - Sea - py",
"SourceFolder": "220_phys",
"RegExp": "^[a-z]{3}_phys_ocn_py_(.*?).shp$",
"DefinitionQuery": "None",
"Display": "Yes"
},
Fields
# | Field | Description |
---|---|---|
1 | MapFrame |
Name of the Map Frame that the layer is to be added to |
2 | LayerGroup |
Layer Group (:warning: NOT CURRENTLY IN USE) |
3 | LayerName |
Name of the Layer. This must correlate with the layerFile.Name field in the recipe.json file. |
4 | SourceFolder |
Folder under the <root>/GIS/2_Active_Data directory |
5 | RegExp |
Regular Expression. Used when selecting files to display |
6 | DefinitionQuery |
Definition Query |
7 | Display |
Shows if set to 'Yes' |
Progress
# | Tested | MapFrame | LayerGroup | LayerName | SourceFolder | RegExp | DefinitionQuery | Display | |
---|---|---|---|---|---|---|---|---|---|
1 | :heavy_check_mark: | Main Map | None | Settlements - Places | 229_stle | ^[a-z]{3}stle_stl_pt(.?)_(.?)([phm][phm])(.*?).shp$ | "place IN ('national_capital', 'city')" | Yes | |
2 | :heavy_check_mark: | Main Map | Transport Points | Transport - Seaports | 232_tran | ^[a-z]{3}tran_sea_pt(.?)_(.?)([phm][phm])(.*?).shp$ | Yes | ||
3 | :heavy_check_mark: | Main Map | Admin - lines | Elevation - Coastline | 211_elev | ^[a-z]{3}elev_cst_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
4 | :heavy_check_mark: | Main Map | Provinces | Provinces | 202_admn | ^[a-z]{3}admn_ad1_py(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
5 | :heavy_check_mark: | Main Map | Admin Lines | Borders - Admin 0 | 202_admn | ^[a-z]{3}admn_ad0_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
6 | :heavy_check_mark: | Main Map | Admin Lines | Borders - Admin 1 | 202_admn | ^[a-z]{3}admn_ad1_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
7 | :heavy_check_mark: | Location Map | Admin Lines | Borders - Admin 2 | 202_admn | ^[a-z]{3}admn_ad2_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
8 | :heavy_check_mark: | Main Map | Transport Lines | Transport - Rail | 232_tran | ^[a-z]{3}tran_rrd_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
9 | :heavy_check_mark: | Main Map | Transport Points | Transport - Airports | 232_tran | ^[a-z]{3}tran_air_pt(.?)_(.?)([phm][phm])(.*?).shp$ | Yes | ||
10 | :heavy_check_mark: | Main Map | None | Cartography - Feather | 207_carto | ^[a-z]{3}carto_fea_py(.?)_(.?)_pp.shp$ | Yes | ||
11 | :heavy_check_mark: | Main Map | Physical | Physical - Lakes | 221_phys | ^[a-z]{3}phys_lak_py(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
12 | :heavy_check_mark: | Main Map | Physical | Physical - Rivers | 221_phys | ^[a-z]{3}phys_riv_ln(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
13 | :heavy_check_mark: | Main Map | Admin Polygons | Admin - Ad 1 Polygon | 202_admn | ^[a-z]{3}admn_ad1_py(.*?).shp$ | Yes | ||
14 | :heavy_check_mark: | Main Map | Admin Polygons | Admin - Ad 2 Polygon | 202_admn | ^[a-z]{3}admn_ad2_py(.*?).shp$ | Yes | ||
15 | :heavy_check_mark: | Main Map | Admin Polygons | Admin - Ad 3 Polygon | 202_admn | ^[a-z]{3}admn_ad3_py(.*?).shp$ | Yes | ||
16 | :heavy_check_mark: | Main Map | Admin Polygons | Admin - Ad 4 Polygon | 202_admn | ^[a-z]{3}admn_ad4_py(.*?).shp$ | Yes | ||
17 | :heavy_check_mark: | Main Map | Admin Polygons | Admin 0 - Affected Country | 202_admn | ^[a-z]{3}admn_ad0_py(.?)_(.?)_([phm][phm]).shp$ | """ADM0_NAME"" = '{COUNTRY_NAME}'" | Yes | |
18 | :heavy_check_mark: | Main Map | Admin Polygons | Admin 0 - Surrounding Country | 202_admn | ^[a-z]{3}admn_ad0_py(.?)_(.?)_([phm][phm]).shp$ | "NOT ""ADM0_NAME"" = '{COUNTRY_NAME}'" | Yes | |
19 | :heavy_check_mark: | Main Map | Elevation | Physical - Sea | 221_phys | ^[a-z]{3}phys_sea_py(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
20 | :heavy_check_mark: | Main Map | Imagery | Imagery - Imagery | 216_imgy | ^[a-z]{3}img_aer_ras_su_unknown_mp_tile\d*.TIF$ | Yes | ||
21 | Main Map | Elevation | Elevation - DEM | 211_elev | ^Rasters.gdb/[a-z]{3}elev_dem_ras(.*?)$ | Yes | |||
22 | :heavy_check_mark: | Main Map | Elevation | Elevation - DEM | 211_elev | ^[a-z]{3}elev_dem_ras(.*?).tif$ | Yes | ||
23 | :heavy_check_mark: | Main Map | Elevation | Elevation - Hillshade | 211_elev | ^[a-z]{3}elev_hsh_ras(.?)_(.?)([phm][phm])((.+)).tif$ | Yes | ||
24 | :heavy_check_mark: | Main Map | Elevation | Elevation - Curvature | 211_elev | ^[a-z]{3}elev_cur_ras(.?)_(.?)([phm][phm])((.+)).tif$ | Yes | ||
25 | :heavy_check_mark: | Main Map | Transport Lines | Transport - Roads | 232_tran | ^[a-z]{3}tran_rds_ln(.?)_(.?)_([phm][phm]).shp$ | highway = 'primary' | Yes | |
26 | :heavy_check_mark: | Main Map | Population | Population | 223_popu | ^[a-z]{3}popu_pop_ras(.?)_(.?)_([phm][phm]).tif$ | Yes | ||
27 | Main Map | Legend | Legend - Roads | 232_tran | ^[a-z]{3}tran_rds_ln(.?)_(.?)([phm][phm])((.+)) | No | |||
28 | Main Map | Legend | Legend - Water | 221_phys | tbd | No | |||
29 | :heavy_check_mark: | Location Map | None | Location Map - Admin 0 Polygon | 202_admn | ^[a-z]{3}admn_ad0_py(.?)_(.?)_([phm][phm]).shp$ | Yes | ||
30 | :heavy_check_mark: | Location Map | None | Location - Surrounding Country | 202_admn | ^[a-z]{3}admn_ad0_py(.?)_(.?)([phm][phm])((.+)) | Yes |
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 | --layerDirectory |
Path to the Layer File directory. |
6 | --product |
Name of product (must correlate with a product in the cookbook file). |
7 | --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\316_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" \
--layerDirectory "D:\MapAction\2019-06-25 - Automation - El Salvador\GIS\3_Mapping\38_Initial_Maps_Layer_Files\All" \
--product "Country Overview" \
--country "El Salvador"
Result
This Country Overview
map was generated:
File Types
The current implementation supports the following geospatial file types:
- Shape files (.shp)
- TIF files (.TIF)
- File Geodatabases (.gdb)
Packaging
python setup.py bdist_wheel
Installing
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.
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):
- A copy of all layer
.lyr
files from the directories under\GIS\3_Mapping\38_Initial_Maps_Layer_Files\*
were copied to a folder namedAll
under the crash move folder at the following location:\GIS\3_Mapping\38_Initial_Maps_Layer_Files\All
- Layer properties file layerProperties.json copied to new directory under the crash move folder at the following location:
\GIS\3_Mapping\31_Resources\316_Automation
- Map cookbook file mapCookbook.json copied to directory under the crash move folder at the following location:
\GIS\3_Mapping\31_Resources\316_Automation
Authors
- Steve Hurst - https://github.com/mapaction/mapactionpy_arcmap
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
File details
Details for the file mapactionpy_arcmap-0.2.dev20.tar.gz
.
File metadata
- Download URL: mapactionpy_arcmap-0.2.dev20.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a27450ae623a88c3cc4d00d9bdc7c0cfcd182774fd65d06e7933a493b1c8e0f |
|
MD5 | f420add8abbdff06d98bdcc696d1e3f3 |
|
BLAKE2b-256 | a7d7db7d250be0286152359ec51038911f4c39d6baf3adaba32922b85c605aa4 |