Skip to main content
Solved

check if feature class exists

  • Jul 28, 2014 6:43 PM UTC
  • 6 replies
  • 208 views

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
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

takashi
Celebrity
  • Best Answer
  • Jul 29, 2014 7:11 AM UTC
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+23
  • Contributor
  • Aug 8, 2017 7:11 PM UTC

@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+23
  • Contributor
  • Aug 8, 2017 7:31 PM UTC

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+23
  • Contributor
  • Aug 11, 2017 7:11 PM UTC

@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.