Skip to main content
Solved

check if feature class exists


Forum|alt.badge.img
Hello, 

 

 

Is there a way to check if a feature class exists in a file geodatabase . If not , throw an error . 

 

 

Is this possible ?

Best answer by takashi

Hi,

 

 

The Schema (Any Format) reader can be used to read feature schemas from a dataset.

 

The reader creates features each of which contains a schema information including feature class name ("fme_feature_type_name" attribute). You can then determine if required feature class exists.

 

 

Takashi
View original
Did this help you find an answer to your question?

6 replies

takashi
Influencer
  • Best Answer
  • July 29, 2014
Hi,

 

 

The Schema (Any Format) reader can be used to read feature schemas from a dataset.

 

The reader creates features each of which contains a schema information including feature class name ("fme_feature_type_name" attribute). You can then determine if required feature class exists.

 

 

Takashi

@takashi I am pretty new to FME and am wondering how exactly I can check if a feature class exists? I was able to successfully load in the schema of the GDB and I see the attribute mentioned, but what transformer would help me best here? How can simply check if it exists?


courtney_m
Contributor
Forum|alt.badge.img+12
  • Contributor
  • August 8, 2017
mrosenberg57 wrote:

@takashi I am pretty new to FME and am wondering how exactly I can check if a feature class exists? I was able to successfully load in the schema of the GDB and I see the attribute mentioned, but what transformer would help me best here? How can simply check if it exists?

You could use a Tester to test if fme_feature_type_name = <name of feature class you want to check for>

courtney_m
Contributor
Forum|alt.badge.img+12
  • Contributor
  • August 8, 2017

Another option is to use a Creator, AttributeManager, and PythonCaller, as shown in the following screenshot.

I have attached the same workspace for reference.

-Courtney


@courtney_m thank you, but can explain a little about what it is you put together? Why do I need to create a new fc?


courtney_m
Contributor
Forum|alt.badge.img+12
  • Contributor
  • August 11, 2017
mrosenberg57 wrote:

@courtney_m thank you, but can explain a little about what it is you put together? Why do I need to create a new fc?

Sorry for the confusion - my Python function is called CreateFeatureClass, because I modified a function from one of my existing workspaces and forgot to change the name. The script is not actually creating a new feature class - It is just checking the GDB to see if the FC already exists, and if the FC does not exist, it prints "Error" in the log window.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings