Project¶
| CLASS | DESCRIPTION |
|---|---|
BookmarkMapSeries |
Wrapper around an arcpy.mp BookmarkMapSeries object that provides an ergonomic interface |
Layer |
mp.Layer wrapper |
Layout |
|
Manager |
Base access interfaces for all manager classes. Specific interfaces are defined in the subclass |
Map |
|
MapSeries |
Wrapper around an arcpy.mp MapSeries object that provides an ergonomic interface |
MappingWrapper |
Internal wrapper class for wrapping existing objects with new functionality |
Project |
Wrapper for an ArcGISProject (.aprx) |
Table |
|
Wildcard |
Clarify that the string passed to a Manager index is a wildcard so the type checker knows you're getting a Sequence back |
| FUNCTION | DESCRIPTION |
|---|---|
name_of |
Handle the naming hierarchy of mapping objects URI -> longName -> name |
safe_name |
Remove invalid filename characters from a string |
BookmarkMapSeries
¶
BookmarkMapSeries(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[BookmarkMapSeries, CIMBookmarkMapSeries], BookmarkMapSeries
Wrapper around an arcpy.mp BookmarkMapSeries object that provides an ergonomic interface
| METHOD | DESCRIPTION |
|---|---|
__getitem__ |
Allow indexing the BookmarkMapSeries by name, index, or Bookmark object |
| ATTRIBUTE | DESCRIPTION |
|---|---|
parent |
The parent object for the wrapper
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
__getitem__
¶
__getitem__(
page: int | str | Bookmark,
) -> BookmarkMapSeries
Allow indexing the BookmarkMapSeries by name, index, or Bookmark object
Source code in src/arcpie/project.py
251 252 253 254 255 256 257 258 259 260 | |
Layer
¶
Layer(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[Layer, CIMBaseLayer], Layer
mp.Layer wrapper
| METHOD | DESCRIPTION |
|---|---|
export_lyrx |
Export the layer to a lyrx file in the target directory |
import_lyrx |
Import the layer state from an lyrx file |
| ATTRIBUTE | DESCRIPTION |
|---|---|
feature_class |
Get a
TYPE:
|
lyrx |
Get a dictionary representation of the layer that can be saved to an lyrx file using |
parent |
The parent object for the wrapper
|
symbology |
Get the base symbology object for the layer
TYPE:
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
feature_class
property
¶
feature_class: FeatureClass
Get a arcpie.FeatureClass object that is initialized using the layer and its current state
lyrx
property
¶
Get a dictionary representation of the layer that can be saved to an lyrx file using json.dumps
Note
GroupLayer objects will return a lyrx template with all sub-layers included
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
export_lyrx
¶
Export the layer to a lyrx file in the target directory
| PARAMETER | DESCRIPTION |
|---|---|
|
The location to export the mapx to |
Source code in src/arcpie/project.py
200 201 202 203 204 205 206 207 208 209 210 | |
import_lyrx
¶
Import the layer state from an lyrx file
| PARAMETER | DESCRIPTION |
|---|---|
|
The lyrx file to update this layer with |
Note
CIM changes require the APRX to be saved to take effect. If you are accessing this
layer via a Project, use project.save() after importing the layerfile
Source code in src/arcpie/project.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
Layout
¶
Layout(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[Layout, CIMLayout], Layout
| METHOD | DESCRIPTION |
|---|---|
to_pdf |
Get the bytes for a pdf export of the Layout |
| ATTRIBUTE | DESCRIPTION |
|---|---|
mapseries |
Get the Layout MapSeries/BookmarkMapSeries if it exists
TYPE:
|
pagx |
Access the raw CIM dictionary of the layout |
parent |
The parent object for the wrapper
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
mapseries
property
¶
mapseries: MapSeries | BookmarkMapSeries | None
Get the Layout MapSeries/BookmarkMapSeries if it exists
pagx
property
¶
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
to_pdf
¶
Get the bytes for a pdf export of the Layout
| PARAMETER | DESCRIPTION |
|---|---|
|
Optional settings for the export (default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
Raw bytes of the PDF for use in a write operation or stream |
Example
# Get the layout object from a project file
lyt = prj.layouts['Layout_1']
# Create a pdf then write the output of to_pdf to it
pdf = Path('pdf_path').write_bytes(lyt.to_pdf())
Source code in src/arcpie/project.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
Manager
¶
Manager(objs: Iterable[_MappingObject])
Bases: Generic[_MappingObject]
Base access interfaces for all manager classes. Specific interfaces are defined in the subclass
Index itentifiers are URI -> longName -> name depending on what is available in the managed class
| METHOD | DESCRIPTION |
|---|---|
__contains__ |
Check to see if a URI/name is present in the Manager |
__getitem__ |
Access objects using a regex pattern (re.compile), wildcard (STRING), index, slice, name, or URI |
get |
Get a value from the Project with a safe default value |
| ATTRIBUTE | DESCRIPTION |
|---|---|
names |
Get the names of all managed objects (skips URIs) |
objects |
Get a list of all managed objects
TYPE:
|
uris |
Get URIs/CIMPATH for all managed objects |
Source code in src/arcpie/project.py
631 632 633 634 635 | |
uris
property
¶
Get URIs/CIMPATH for all managed objects
Note
Default to a Python id() call if no URI is present
__contains__
¶
Check to see if a URI/name is present in the Manager
Source code in src/arcpie/project.py
705 706 707 708 709 710 711 | |
__getitem__
¶
__getitem__(
name: str | Wildcard | Pattern[str] | int | slice,
) -> _MappingObject | list[_MappingObject]
Access objects using a regex pattern (re.compile), wildcard (STRING), index, slice, name, or URI
Source code in src/arcpie/project.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | |
get
¶
get(
name: str | Wildcard, default: _Default | None = None
) -> (
_MappingObject | list[_MappingObject] | _Default | None
)
Get a value from the Project with a safe default value
Source code in src/arcpie/project.py
698 699 700 701 702 703 | |
Map
¶
Map(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[Map, CIMMapDocument], Map
- Modules Project
| METHOD | DESCRIPTION |
|---|---|
export_assoc_lyrx |
Export all child layers to lyrx files the target directory |
export_mapx |
Export the map definitions to a mapx file in the target directory |
import_assoc_lyrx |
Imports lyrx files that were exported using the |
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmarks |
Get a BookmarkManager for all bookmarks in the Map
TYPE:
|
elevation_surfaces |
Get an ElevationSurfaceManager for all elevation surfaces in the Map
TYPE:
|
layers |
Get a LayerManager for all layers in the Map
TYPE:
|
local_layers |
Get a LayerManager for all non-web layers in the Map
TYPE:
|
parent |
The parent object for the wrapper
|
tables |
Get a TableManager for all tables in the Map
TYPE:
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
bookmarks
cached
property
¶
bookmarks: BookmarkManager
Get a BookmarkManager for all bookmarks in the Map
elevation_surfaces
cached
property
¶
elevation_surfaces: ElevationSurfaceManager
Get an ElevationSurfaceManager for all elevation surfaces in the Map
local_layers
cached
property
¶
local_layers: LayerManager
Get a LayerManager for all non-web layers in the Map
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
export_assoc_lyrx
¶
export_assoc_lyrx(
out_dir: Path | str,
*,
skip_groups: bool = False,
skip_grouped: bool = False,
) -> None
Export all child layers to lyrx files the target directory
| PARAMETER | DESCRIPTION |
|---|---|
|
The location to export the lyrx files to |
|
Skip group layerfiles and export each layer individually in a group subdirectory (default: False)
TYPE:
|
|
Inverse of skip groups and instead only exports the group lyrx, skipping the individual layers (default: False)
TYPE:
|
Source code in src/arcpie/project.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
export_mapx
¶
Export the map definitions to a mapx file in the target directory
| PARAMETER | DESCRIPTION |
|---|---|
|
The location to export the mapx to |
Source code in src/arcpie/project.py
428 429 430 431 432 433 434 435 | |
import_assoc_lyrx
¶
Imports lyrx files that were exported using the export_assoc_lyrx method
| PARAMETER | DESCRIPTION |
|---|---|
|
The directory containing the previously exported lyrx files |
Note
CIM changes require the APRX to be saved to take effect. If you are accessing this
layer via a Project, use project.save() after importing the layerfile
Source code in src/arcpie/project.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
MapSeries
¶
MapSeries(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[MapSeries, CIMMapSeries], MapSeries
Wrapper around an arcpy.mp MapSeries object that provides an ergonomic interface
- Modules Project
| METHOD | DESCRIPTION |
|---|---|
__getitem__ |
Allow indexing a mapseries by a page name or a page index/number |
to_pdf |
Export the MapSeries to a PDF, See Layer.to_pdf for more info |
| ATTRIBUTE | DESCRIPTION |
|---|---|
current_page_name |
Get the name of the active mapseries page
TYPE:
|
feature_class |
Get the FeatureClass of the parent layer
TYPE:
|
layer |
Get the mapseries target layer
TYPE:
|
map |
Get the map object that is being seriesed
TYPE:
|
pageRow |
Get a Row object for the active mapseries page
|
page_field |
Get fieldname used as pagename
TYPE:
|
page_field_names |
Get all fieldnames for the mapseriesed features |
page_values |
Get a mapping of values for the current page |
parent |
The parent object for the wrapper
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
valid_pages |
Get all valid page names for the MapSeries |
Source code in src/arcpie/project.py
95 96 97 | |
page_field_names
cached
property
¶
Get all fieldnames for the mapseriesed features
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
__getitem__
¶
Allow indexing a mapseries by a page name or a page index/number
Source code in src/arcpie/project.py
347 348 349 350 351 352 353 354 355 356 357 358 | |
to_pdf
¶
Export the MapSeries to a PDF, See Layer.to_pdf for more info
| PARAMETER | DESCRIPTION |
|---|---|
|
Passthrough kwargs for layout.exportToPDF
TYPE:
|
Note
By default, printing a mapseries will print all pages to a single file. To only print the active page:
>>> ms.to_pdf(page_range_type='CURRENT')
Source code in src/arcpie/project.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
MappingWrapper
¶
MappingWrapper(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: Generic[_MapType, _CIMType]
Internal wrapper class for wrapping existing objects with new functionality
Usage
>>> MappingWraper[mp.<type>, cim.<type>](mp.<type>)
Note
All
| ATTRIBUTE | DESCRIPTION |
|---|---|
parent |
The parent object for the wrapper
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
Project
¶
Wrapper for an ArcGISProject (.aprx)
Usage
>>> prj = Project('<path/to/aprx>')
>>> lay = prj.layouts.get('My Layout')
>>> Path('My Layout.pdf').write_bytes(prj.layouts.get('My Layout').to_pdf())
4593490 # Bytes written
>>> for map in prj.maps:
... print(f'{map.name} has {len(map.layers)} layers')
My Map has 5 layers
My Map 2 has 15 layers
Other Map has 56 layers
| METHOD | DESCRIPTION |
|---|---|
__getitem__ |
Resolve the name by looking in Maps, then Layouts, then Reports |
export_layers |
Export all layers in the project to a structured directory of layerfiles |
export_mapx |
Export all maps to a directory |
export_pagx |
Export all layouts to a directory |
import_layers |
Import a structured directory of layerfiles generated with |
import_mapx |
Import a mapx file into this project |
import_pagx |
Import a pagx file into this project |
refresh |
Clear cached object managers |
save |
Save this project |
save_as |
Saves the project under a new name |
| ATTRIBUTE | DESCRIPTION |
|---|---|
aprx |
Get the base ArcGISProject for the Project
TYPE:
|
broken_layers |
Get a LayerManager for all layers in the project with broken datasources
TYPE:
|
broken_tables |
Get a TableManager for all tables in the project with broken datasources
TYPE:
|
layouts |
Get a LayoutManager for the Project layouts
TYPE:
|
maps |
Get a MapManager for the Project maps
TYPE:
|
name |
Get the file name of the wrapped aprx minus the file extension
TYPE:
|
reports |
Get a ReportManager for the Project reports
TYPE:
|
Source code in src/arcpie/project.py
744 745 | |
broken_layers
property
¶
broken_layers: LayerManager
Get a LayerManager for all layers in the project with broken datasources
broken_tables
property
¶
broken_tables: TableManager
Get a TableManager for all tables in the project with broken datasources
__getitem__
¶
Resolve the name by looking in Maps, then Layouts, then Reports
Source code in src/arcpie/project.py
815 816 817 818 819 820 | |
export_layers
¶
export_layers(
target_dir: Path | str,
*,
skip_groups: bool = False,
skip_grouped: bool = False,
) -> None
Export all layers in the project to a structured directory of layerfiles
| PARAMETER | DESCRIPTION |
|---|---|
|
The target directory to export the layerfiles to |
|
Skip group layerfiles and export each layer individually in a group subdirectory (default: False)
TYPE:
|
|
Inverse of skip groups and instead only exports the group lyrx, skipping the individual layers (default: False)
TYPE:
|
Source code in src/arcpie/project.py
914 915 916 917 918 919 920 921 922 923 924 | |
export_mapx
¶
Export all maps to a directory
Source code in src/arcpie/project.py
907 908 909 910 911 912 | |
export_pagx
¶
Export all layouts to a directory
Source code in src/arcpie/project.py
878 879 880 881 882 883 | |
import_layers
¶
Import a structured directory of layerfiles generated with export_layers
| PARAMETER | DESCRIPTION |
|---|---|
|
A directory containing layer files in map directories and group directories |
Note
CIM changes require the APRX to be saved to take effect. If you are accessing this
layer via a Project, use project.save() after importing the layerfile
Source code in src/arcpie/project.py
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | |
import_mapx
¶
Import a mapx file into this project
| PARAMETER | DESCRIPTION |
|---|---|
|
The path to the mapx document |
| RETURNS | DESCRIPTION |
|---|---|
Map
|
A Map parented to this project |
Source code in src/arcpie/project.py
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | |
import_pagx
¶
Import a pagx file into this project
| PARAMETER | DESCRIPTION |
|---|---|
|
The path to the pagx document |
| RETURNS | DESCRIPTION |
|---|---|
Layout
|
A Layout parented to this project |
Source code in src/arcpie/project.py
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | |
refresh
¶
Clear cached object managers
| PARAMETER | DESCRIPTION |
|---|---|
|
Optionally limit cache clearing to certain managers (attribute name)
TYPE:
|
Source code in src/arcpie/project.py
946 947 948 949 950 951 952 953 954 955 | |
save
¶
save() -> None
Save this project
Source code in src/arcpie/project.py
832 833 834 | |
save_as
¶
Saves the project under a new name
| PARAMETER | DESCRIPTION |
|---|---|
|
The filepath of the new aprx |
| RETURNS | DESCRIPTION |
|---|---|
Project
|
A Project representing the new project file |
Note
Saving a Project as a new project will not update this instance, and instead returns a new Project instance targeted at the new file
Source code in src/arcpie/project.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | |
Table
¶
Table(
obj: _MapType,
parent: _MappingObject | Project | None = None,
)
Bases: MappingWrapper[Table, CIMStandaloneTable], Table
| METHOD | DESCRIPTION |
|---|---|
export_lyrx |
Export the layer to a lyrx file in the target directory |
import_lyrx |
Import the table state from an lyrx file |
| ATTRIBUTE | DESCRIPTION |
|---|---|
parent |
The parent object for the wrapper
|
table |
Get an
TYPE:
|
unique_name |
Get the longName or name of the object. Use id for any object without a name attribute
TYPE:
|
uri |
Get the URI for the object or the id with
TYPE:
|
Source code in src/arcpie/project.py
95 96 97 | |
parent
property
¶
parent
The parent object for the wrapper
Project -> Map -> Layer
Project -> Layout -> Map -> MapSeries
Project -> Report
The general parent/child relationships are based on how you would access the object in ArcPro. Projects have maps, maps have layers, layouts have mapseries etc.
unique_name
property
¶
unique_name: str
Get the longName or name of the object. Use id for any object without a name attribute
export_lyrx
¶
Export the layer to a lyrx file in the target directory
| PARAMETER | DESCRIPTION |
|---|---|
|
The location to export the lyrx to |
Source code in src/arcpie/project.py
559 560 561 562 563 564 565 566 567 568 | |
import_lyrx
¶
Import the table state from an lyrx file
| PARAMETER | DESCRIPTION |
|---|---|
|
The lyrx file to update this table with |
Note
CIM changes require the APRX to be saved to take effect. If you are accessing this
layer via a Project, use project.save() after importing the layerfile
Source code in src/arcpie/project.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
Wildcard
¶
Bases: UserString
Clarify that the string passed to a Manager index is a wildcard so the type checker knows you're getting a Sequence back
- Modules Project
name_of
¶
Handle the naming hierarchy of mapping objects URI -> longName -> name
Allow setting flags to get specific names
Note
If a URI is requested and no URI attribute is available in object,
'obj.name: NO URI(id(obj))' will be returned, e.g. 'my_bookmark: NO URI(1239012093)'
Source code in src/arcpie/project.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | |