2

I have feature layers that have a different name in the TOC then that they do in the GDB. I cannot change either of these and I need the name of the feature class from the GDB in order to make my model work. I have tried things such as parse path but I only get the name of the layer as it is in the TOC.

I have tried a few ArcPy/Python methods, but with my little knowledge of these things, I could not figure out how to get the GDB name as an output parameter.

I am using ArcMap version 10.3.1

Below I have added an example of my model and the code I last used to try and get the name.

Example of model

import os
import arcpy
layer = arcpy.GetParameter(0)
print(os.path.basename(layer))
Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked May 21, 2019 at 11:33
1
  • arcpy.Describe(lyr).name Commented May 21, 2019 at 12:13

1 Answer 1

2

You are trying to treat a spatial dataset as if it is a normal file so you are accessing properties that are not appropriate (i.e. os.path.basename). I would use the Calculate value tool but you could easily adapt your existing script if you wish.

Model

The Calculate value tool is set up as:

Tool

You would change the parameter highlighted in red to what every you are using, don't ignore the quotes around it.

answered May 21, 2019 at 12:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.