How can I "store relative pathnames" in ArcGIS Pro?

42688
26
Jump to solution
08-30-2017 04:09 AM
SabineSchnichels
New Contributor

Are absolute pathnames the default option? Does ArcGIS Pro always store absolute pathnames or is there a possibility to change this to relative?

1 Solution

Accepted Solutions
BarryFosberg
New Contributor III

At this point I have project templates.  I will be posting a further question on a thread about Templates verses Packages, but this one is about relative path names.

long set up :

My Goal is a template or package that will allow a particular project to be loaded onto  another machine and run a map project from that machine. In this project the user will supply one data table and it along with one pre-existing feature layer will be put through two models.  The other user should be able to function without any path to any existing data source.

A further complexity is that we are in a One Drive environment. ESRI has not solved all of the problems associated with One Drive. That again is a separate issue.

The one feature that the user must have to run either of this project's two tools is stored in a geodatabase. It looks like the geodatabase is recreated in each new project made from the template. So far so good.

What I cannot test, for the moment, is how well this works from another computer. 

Almost there:

The tools that calls for the feature class seems to work with a path to the geoodatabase like this:

C:\Users\MYLoginName\OneDrive(localDirectory)\HomeDirectory\Map1FmTemplate3_21\MapProject1.gdb .

 

Un fortunately the tool opens in the new project map asking for the feature class with the path:

C:\Users\My long in name\OneDrive - HPD\(Subfolder where the original map project was developed\MapProject1\MapProject1.gdb\feature name

Footnote, the subfolder: OneDrive(localDirectory) is always on my computer and in the cloud, apparently solving some ESRI/ArcPro issues. I am using my C: drive to save computer operating time as our server connection is not that robust.  

 

Actual Question:

In the Template, I think I need to change the path to the geodatabase to something like:

C:\Users\%anyones login name%\

OneDrive(localDirectory)\HomeDirectory\Map1FmTemplate3_21\MapProject1.gdb .

For %anyones login name%

I have tried %name% and %username%

Any suggestion as to the right inline variable to allow a path to whatever C drive is the host drive for their new map project?

 

Bonus Question

The feature class is in the geodatabase in the newly created map project. How do I design the model so that it does not look to the geodatabase back in the original, project development geodatabase?

View solution in original post

0 Kudos
26 Replies
DanPatterson_Retired
MVP Emeritus

The concept of relative paths is a bit different.  When you create a project you can have a structure set up for you 

so in theory, your geodatabase, home folder etc is already created.

Can you be specific about what it is you are trying to do.  When you move 'stuff' if everything is moved 'relative' to the aprx, then there shouldn't be a problem

0 Kudos
DanPatterson_Retired
MVP Emeritus

Check this link...

you may wish to set up a project template for current and future use so your connections are maintained.

0 Kudos
MarcoBoeringa
MVP Regular Contributor

Does ArcGIS Pro always store absolute pathnames or is there a possibility to change this to relative?

As far as I understood it, it is exactly the opposite of what you are writing: Pro defaults to using relative paths. This is why there is no setting for relative paths like in ArcMap.

The only "but..." is that, of course, as with ArcMap, in order to have Pro save relative paths, both your data and your project must reside on the same drive. If a certain data set used in your project is on C: and your Pro project (*.aprx) is on 😧, there is no other option for Pro than to save the particular data source with an absolute path. This is no different than ArcMap.

I just tested this out to be sure by moving a Pro project of mine from my 😧 to my C: drive (with all my data referenced from D originally). The project opened fine on C:, and the layer properties show the C: drive as data source. This is a clear indication of default relative paths in the project.

PaulDoherty2
Occasional Contributor III

Dan Patterson‌ et al. 

We (+Alix Vezina) are working on a shareable ArcGIS Pro "template" but have hit two major issues.

Link: https://www.arcgis.com/home/item.html?id=ee44dd7cd11c4017a67d43fcbb1cb467 

1) Project Template: When using a Project Template, ArcGIS Pro Tasks could not find the models we built and totally broke. Let's skip this for now because maybe templates are not a good approach.

2) Zip and Ship: When we use a more "classic" approach of zipping up all of the resources (ArcGIS Pro Project File, Toolbox, GDB, Folders) - this problem is resolved but we run into another similar relative path issue. 

If our Task references a geoprocessing tool or model, the predefined inputs / outputs are still pointing to the original PC. What is the best way to resolve this? 

Screenshot below shows it references C:\Users\avezina but this is Alix' PC not mine  Note inputs that point to feature layers in the web map are not broken, just the local feature classes stored in the .gdb. Whether it is the Default .gdb or other. 

Any help you can provide would be fantastic! As a non-profit we do not get access to Esri Support for ArcGIS Pro  

DanPatterson_Retired
MVP Emeritus

We have an expression in our teaching labs... "Users is for Losers"  if you want to lose data, have difficulty accessing data, use your 'users' folder .  Sadly it is the default for many programs for installations of 'clones' and other such beasts.

The solution is to ensure that you are aware of the pitfalls and try to avoid them from the get-go.

Here are some examples below, with more at...

/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python 

# ---- success 1, use 'raw' encoding (small 'r' in front of path)
pth = r"C:\Users\avezina"
print(pth)
C:\Users\avezina

# ---- fail 1, \U is a unicode no-no
pth = "C:\Users\avezina"
  File "<ipython-input-3-6108ffe99c8b>", line 1
    pth = "C:\Users\avezina"
         ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape


# ---- success 2, use forward slashes, but hard to set up without reading a bad path
pth = "C:/Users/avezina"
print(pth)
C:/Users/avezina


# ---- fail 2, you get quasi-smart and switch folders, but discover that there
# are other fails, like \a, \t, \n plus others

pth = "C:\other_folder\avezina"

print(pth)
C:\other_foldervezina‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

If you were running a script in a tool in a toolbox, I would have a direct option.

I always set my 'paths' relative to the running script

import sys

script = sys.argv[1]

This gives the path to the running script... I just parse off the bits I don't want and append the location of such things as other folders and gdb's because I have everything to be contained in one folder when I 'zip and ship'

0 Kudos
Chris01
New Contributor

Hey Paul, by any chance did you figure this issue out? Currently having a similar issue..

0 Kudos
PaulDoherty2
Occasional Contributor III

Dan Patterson‌ thank you for the quick reply. As soon as I clicked "Post" I thought of this myself. When I used to teach ArcMap I encouraged the use of C:/GIS and will go back to that here for this lesson. I just had hoped ArcGIS Pro somehow fixed this since it defaults to the "Documents" folder. It just shows, sometimes you have to go back to basic GIS101! 

0 Kudos
by Anonymous User
Not applicable

Has anyone figured out how to use relative links in Pro? This is what my links like in ArcMap. The hyperlink lightning bolt is there.

This is what the look like in Pro.

Do the links need to be in a different format. I want to move my clients to Pro but how will links relative links work?

by Anonymous User
Not applicable

Bump. So is there no way to do this? I can have relative links in ArcMap but not pro? I really have to put file:/// in front of the link?