Select to view content in your preferred language

Model Builder save output layer file in data source path

326
6
Jump to solution
07-02-2024 01:18 AM
FabioTuccini
New Contributor II

Hello,

I'm trying to create a model builder to save the layer file (.lyrx) in the same path of the data source.

Using the parse path the output path is the project folder and not the data source folder path.

here below an image of the model builder.

Someone can help please.

Screenshot 2024-07-02 101719.jpg

0 Kudos
1 Solution

Accepted Solutions
RichardHowe
Occasional Contributor III

I would start here, there's a useful walk through and some code snippets which should familiarise you with what you want to do

Five python code snippets for arcgis pro 

Also, the help page for every geoprocessing tool that you might ever have wanted to drag into model builder incldues a python snippet and example to show how to use it.

In broad terms then your python process will effectively be a case of listing the layers in your map, creating a for loop and saving to a layer file for each.

View solution in original post

0 Kudos
6 Replies
RichardHowe
Occasional Contributor III

The iterate layers tool will return that path as that;s where the layer lives.

If you want the actual data source then look at making a workspace (the folder containing your data) your input variable (rather than a map) and iterating datasets then parsing that path.

Alternatively have a look at python and listLayers, which will give you much more flexibility and the ability to interrogate all the layer properties, including data source.

0 Kudos
FabioTuccini
New Contributor II

Thanks, but using the iterate workspace I can't use the tool save to layer file.

0 Kudos
RichardHowe
Occasional Contributor III

Ah yeah, that;s fair. I would definitely look into python then. I realise it can be daunting at first, but honestly once you get going and you see the possibilities, you'll never look back at model builder.

0 Kudos
FabioTuccini
New Contributor II

Ok. i'll try in python. I never used before, any suggestion that can guide me to solve my problem?

RichardHowe
Occasional Contributor III

I would start here, there's a useful walk through and some code snippets which should familiarise you with what you want to do

Five python code snippets for arcgis pro 

Also, the help page for every geoprocessing tool that you might ever have wanted to drag into model builder incldues a python snippet and example to show how to use it.

In broad terms then your python process will effectively be a case of listing the layers in your map, creating a for loop and saving to a layer file for each.

0 Kudos
BobBooth1
Esri Contributor

More resources for learning Python in ArcGIS Pro can be found here:

https://learn.arcgis.com/en/paths/learn-python-in-arcgis-pro/

0 Kudos