I was wondering if there is a ArcPy function to create a new project from scratch given a root directory where I would want the project to be created.
Hey @YahyaMasri
Here's a link to a similar post, would this work for you?
The gist is to have a blank template project, and then copy that project to make a new blank one.
Cody
Thanks for the quick reply, Cody!
Is there no other way to create a new project if there is for example no blank template project? Thanks for the help and the link!
Hey @YahyaMasri
No problem! From what I've found, it doesn't appear to currently be a function within the documentation, I saw someone had mentioned a create() function, but that doesn't exist.
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject.htm
Definitely suitable for an idea on the ideas forum!
Cody
You can use the ConvertWebMapToProject function with a minimal map definition to get a project file in memory, which you can then save to disk:
z = arcpy.mp.ConvertWebMapToArcGISProject("""{
"mapOptions": {
"extent": {
"xmin": -12933906.537,
"ymin": 3993856.886,
"xmax": -12933371.998,
"ymax": 3994375.189,
"spatialReference": {
"wkid": 102100
}
}
},
"operationalLayers": [],
"baseMap": [],
"exportOptions": {},
"layoutOptions": {},
"reportOptions": {}
}""").ArcGISProject.saveACopy(r"C:\path\to\project.aprx")
A bit hacky but it works. If you want a more comprehensive project as a base you're better off with @CodyPatterson's template method.