Solved

Writing empty shapefiles

  • 25 November 2021
  • 3 replies
  • 34 views

I receive an empty shapefile from our client and if I don't add any features, have to rename it.

Since FME is feature based it won't write to a new shapefile if empty.

 

The shapefile can also not contain a null feature so the NoFeatureTester or a null Creator is not an option.

I'm currently on FME version 2019.2.1

 

How can I write empty shapefiles?

icon

Best answer by ebygomm 25 November 2021, 14:51

View original

3 replies

Userlevel 1
Badge +21

I think if the empty shapefile already exists, you can use a FileCopyWriter to rename it

Userlevel 4
Badge +36

You can also create an empty shapefile by passing a feature with no geometry and no attributes. See the lowest branch in the illustration below.

FME Hub contains several transformers that can test for the absence of features.

QGIS will open this shapefile, as will FME Data Inspector (but with a warning).

Create_empty_shapefile_workflow

I think if the empty shapefile already exists, you can use a FileCopyWriter to rename it

The filecopy writer did the trick indeed, using the NoFeaturesTester I check for empty shapefiles and if so, copy the base to my results folder.imageGood to know: the filecopy_source_dataset & filecopy_dest_filename have to be set using an attributecreator

Reply