Select to view content in your preferred language

ArcPy function to create new project

239
4
01-27-2025 12:07 PM
YahyaMasri
Emerging Contributor

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. 

0 Kudos
4 Replies
CodyPatterson
MVP Regular Contributor

Hey @YahyaMasri 

Here's a link to a similar post, would this work for you?

https://community.esri.com/t5/python-questions/arcpy-function-for-creating-a-new-arcgis-project/td-p...

The gist is to have a blank template project, and then copy that project to make a new blank one.

Cody

YahyaMasri
Emerging Contributor

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!

0 Kudos
CodyPatterson
MVP Regular Contributor

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

0 Kudos
DavidSolari
MVP Regular Contributor

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.