Solved

dynamic writer to write empty feature classes


Badge

I have a series of feature readers that read data and schema from a postGIS DB and writes to a GDB using a dynamic writer and the schema feature generated from the Feature reader (see image). For some data I have empty tables and FME does not seem to write the corresponding feature class in GDB if no features are found. Now, what I would like to achieve is to force FME to write every feature class (corresponding to a table in the DB) even if the table does not contain any data. Ideally I would need an empty feature class with one row and empty data but also an empty feature class is fine, as long as there is the schema, that would be the requirement. Is it easily possible to achieve in FME desktop?

icon

Best answer by adieporter 7 June 2018, 15:27

View original

7 replies

Badge

Hi Alex

FME has traditionally always required a feature to instigate writing. Therefore using FME to build tables in a new database where data is yet to exist can sometimes be tricky but not impossible.

This would be a good enhancement request to allow schema building even when there is no data!

In your FeatureReader do you get schemas back even when there in no data in the table? Either by trying to read all table in the schema or providing a list of known tables?

If so you could test if there is a match between the read schemas and the read generic data just to identify where there is no data. This coulb be done by using a FeatureMerger testing in the featuire_type_name or possible doing a double FeatureReader first to get schema and second to get feature - this would allow better use in the Initiator matched_records attribute that get created.

When tables with no data has been found you could create a dummy feature. When passed to the writer this will allow FME to create the tables. We obviously do not want to keep this dummy data so I would be tempted to replace the writer with a FeatureWriter. This will allow the process to continue allowing tou to instigate a delete operation.

 

I hope that helps

Adie.

Badge

Hi @adieporter, thanks for your help.Yes, I have the schema in any table I read from the Source DB. The solution you seggested is the one I initially thought apart from testing for empty tables wiht FeatureMerger. I will carry on with this approach.

Userlevel 4

Hi Alex

FME has traditionally always required a feature to instigate writing. Therefore using FME to build tables in a new database where data is yet to exist can sometimes be tricky but not impossible.

This would be a good enhancement request to allow schema building even when there is no data!

In your FeatureReader do you get schemas back even when there in no data in the table? Either by trying to read all table in the schema or providing a list of known tables?

If so you could test if there is a match between the read schemas and the read generic data just to identify where there is no data. This coulb be done by using a FeatureMerger testing in the featuire_type_name or possible doing a double FeatureReader first to get schema and second to get feature - this would allow better use in the Initiator matched_records attribute that get created.

When tables with no data has been found you could create a dummy feature. When passed to the writer this will allow FME to create the tables. We obviously do not want to keep this dummy data so I would be tempted to replace the writer with a FeatureWriter. This will allow the process to continue allowing tou to instigate a delete operation.

 

I hope that helps

Adie.

Great answer. I'll just add that to create the dummy feature, look into the NoFeaturesTester available on the FME Hub.

@alex_chris Did this process work out for you? I am having a very similar issue trying to get my entire schema to write with empty feature classes.

@alex_chris Did this process work out for you? I am having a very similar issue trying to get my entire schema to write with empty feature classes.

https://knowledge.safe.com/articles/40193/how-to-use-an-esri-template.html

This article helped me solve my problem of getting the writer to create a gdb with empty feature classes. I used an XML workspace document as my schema template.

Badge

@alex_chris did you find asolution to write empty table to file geodatabase

 

Userlevel 1
Badge +11

@alex_chris did you find asolution to write empty table to file geodatabase

 

Hi @hamdyahmed,

Have you taken a look at this article on How to Use and Esri Template Geodatabase already as per sarah_vg's suggestion on this thread?

If that doesn't work for you, I'd suggest posting a new question for better visibility. At a glance, this thread looks like ti's been solved and it's easy for the Community to overlook new comments on older Q&A's. Thanks!

Reply