Skip to main content
Solved

check if feature class exists

  • July 28, 2014
  • 6 replies
  • 131 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
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
  • 7842 replies
  • 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

  • 2 replies
  • August 8, 2017

@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+19
  • Contributor
  • 127 replies
  • August 8, 2017

@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+19
  • Contributor
  • 127 replies
  • 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


  • 2 replies
  • August 8, 2017

@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+19
  • Contributor
  • 127 replies
  • August 11, 2017

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