ArcPy should have a function that allows a user to create an .aprx (ArcGIS Pro project).
^^^ That's the idea. ^^^
Right now, we're in something of a chicken / egg situation.
Egg: I want to automate some ArcGIS Pro things
Chicken: Great. You just need to use an existing project.
Egg: What if I want to automate the project creation?
Chicken: Nah. You don't want that mate. Just have something already there.
These Python questions both ask about the existence of a function to create an .aprx:
And in both instances, the solution is some flavor of: yeah sure, you just need to have this thing that already exists to make it work.
Cue slow-blink meme.
Could we imagine a world where, say, Python couldn't generate a new file? No.
I mean, I can't. And what I mean to say, with this very belabored point, is, file handling and I/O is a standard part of any flavor of computer programming. It is basic functionality and expected.
Can ArcPy implement this very standard pattern?
An APRX is different from other stuff since it's a gzipped directory of relationships. You could technically just make it from scratch if you wanted.
Those files are all just json CIM definitions:
All relationships are managed by the Index.json and project settings are in GISProject.json
Here's an Index.json that I visualized with vizjs, it's incredibly complex:
A minimal APRX is just a DocumentInfo.xml, GISProject.json, and Index.json file in a zipped directory (using defalte compression) with the suffix .aprx so Windows knows to use Pro to open it. You can also just right click the zip and open in Pro and it'll work too.
To build the GISProject.json you can use the arcpy.cim module:
from arcpy.cim.CIMDocument import (
CIMGISProject,
CIMModuleSettings,
CIMProjectItem,
CIMDocumentInfo,
)
project = CIMGISProject()
doc_info = CIMDocumentInfo()
# Write out to files and zip
That's totally the point -> We don't build .mapx or .lyrx from scratch.
ArcPy lets us abstract that stuff away. If a sufficiently technical user can create an .aprx from scratch, then how can we rationalize that it is too complicated for the product owners to implement?
Oh I know, I agree that those small steps required to create an APRX should be abstracted behind a function. I was just pointing out the method by which it could be accomplished. The reason they haven't done this is likely because the other .x files are actually just files while .aprx is a zip which doesn't fit well with whatever system they're using to create the others.
This whole setup process could even be implemented in Python since you likely aren't going to need crazy fast performance on a project builder function and it's going to be IO bound anyways.
Was just hoping that showing that manual process could help some people in the meantime and maybe give ESRI a starting point on what to do
Yeah I could really use this function.
Great idea and great job presenting it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.