Question

Question of the Week: Exposing and Using Format Attributes

  • 19 March 2021
  • 1 reply
  • 9 views

Userlevel 4
Badge +25

Question of the Week

It's been a while since I got to highlight a question, for which I apologize. But here is a question that was asked during our recent replay of the Shapefile webinar.

 

"I have a question: I have a large number of shapefiles that I need to turn on some "Format Attributes" like FME_dataset" and "FME_Basename". Is it possible to turn on these format attributes by default when I put the shapefiles on FME workbench?"

 

So let's have a look at how we can do that.

 

Format Attributes

Each feature FME reads has three sets of information. There are user attributes and - for spatial features - there is geometry. But there are other pieces of data that aren't stored in such a way; for example the name of the source dataset, the color of an object, or the size of a piece of text.

 

These are stored as format attributes, and they can be accessed and used in your workspace.

 

Exposing Format Attributes

Normally you expose format attributes in the reader feature type dialog:

QOTW-FormatAttrs1Here I'm exposing the fme_dataset attribute to get information about the source filename.

But exposing them every time you add a reader, to every feature type on the page, would be a pain, right? Not so. There are several ways to help make this easier.

 

Expose Once: Use Many Times

The first thing to note is that these attributes exist on the features whether they are exposed or not. All you achieve by exposing them is to make them available in transformer parameters. For example:

 

QOTW-FormatAttrs2Here I have dozens of source feature types whose fme_dataset value is being used by an AttributeCreator. Do I need to expose it in every source feature type? No! I expose it in one feature type so that I can use it in the AttributeCreator.

But then the fme_dataset values of other feature types are processed correctly anyway, because they still exist.

 

But... what happens if the feature types aren't processed in the same stream (as above)? What then?

 

Apply Exposure to Multiple Feature Types

That scenario looks like this:

QOTW-FormatAttrs3So I have to expose the format attribute in every feature type, right? Yes, that's true, but I can use this option when I do:

QOTW-FormatAttrs4By clicking Apply To I can easily apply the same attributes to expose to every single feature type.

 

But - you now say - what if I want to do the same for every workspace. Can I do that? Of course...

 

Expose Attributes in the Reader and Set as a Preset

When you add a reader to your workspace, one of the parameters asks you about additional attributes to expose:

QOTW-FormatAttrs5Now those attributes are exposed when I add the reader. But can I do that for every new reader (or workspace) I create? Yes! You can simply set these values as a preset:

QOTW-FormatAttrs6 

As long as I save this as the Preferred Default Set, then every time I add a Shapefile reader, those attributes will be exposed automatically!

 

Summary

So there we are. That's how our user from Brazil found out you can easily expose format attributes with just a little bit of setup.

 

Some other questions that I found interesting this week:

  • How to send a query to a Russian geocoder. As was mentioned in a prior Question-of-the-Week, the answer is to make sure the contents are URL encoded with the TextEncoder transformer.
  • How to give employees access to the FME Quick Translator. There must be a way to do this, but really, the proper solution is to install FME Server. As noted, as a local government they even qualify for a subscription license, to make it even easier!
  • How to scale and shift vectors. The answer is to use the AffineWarper transformer. But - you might wonder - what about the RubberSheeter? How is that different? As I understand it, the AffineWarper will calculate a scale, rotation, and offset and apply that to all features. So it's great when a single transformation to everything is needed. But the RubberSheeter will warp the data, so not every feature gets the same scale, rotation, and offset. It's better when the features don't share a consistent transformation across the entire dataset. So now you know!
  • How to read compressed Parquet data. The user was getting an error here, but the new Parquet reader should read such data. So what's going on? The problem was a beta Parquet reader on the FME Hub. It was still installed and somehow got preference. So if you are reading Parquet, just make sure you've uninstalled that old beta package.
  • How to print a workspace at A0 size. Wow! An A0 plot of a workspace would be awesome. Sadly there's a fault in one of the 3rd party libraries we use that means by default A0 won't work. They might fix that bug at any time, so keep trying, but in the meantime, there are other software solutions that will let you print to A0 (see question for details).

 

Have a great weekend everyone.

 

Mark (FME Evangelist)


1 reply

Userlevel 4
Badge +30

Very interesting article @mark2atsafe​ 

Reply