I have a .osm (OpeenStreetMap) file as a reader, then used ListExploder to get the attributes for each feature as it's saved as tags, k (=key), and v (=value) , FME read these tags as a list ,..so I managed to get the columns, but I'm now stuck in how can I convert every key (or k) of the feature, into an attribute, and match to its value (v), see snapshot..
For example, k=maxspeed is an attribute and v= 100 is its value.
Note that every feature may have many k's, (i.e., name, lanes, oneway, maxspeed,..etc)
Any idea? Appreciate it..
Best answer by takashi
Looks like there aren't duplicate tags for each individual feature.
I think the combination (BulkAttributeRenamer+Aggregator) works as expected.
Try modifying the parameters.
BulkAttributeRenamer
- Selected Attributes: v
- Action: Regular Expression Replace
- Text To Find: .+
- String: k <choose the attribute "k">
Aggregator
- Group By: id
- Mode: Attributes Only
- Keep Input Attributes: Yes
And then, add an AttributeExposer to expose required attribute names (e.g. "name", "highway" etc.).
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.
The BulkAttributeRenamer with this setting renames "v" to value of "k" in the same row.
You can then aggregate them for each feature with the Aggregator, grouping by feature ID. If the records don't have feature ID column, consider adding unique ID for each feature with the Counter before the ListExploder.
And the new attribute names will not be exposed automatically. You will have to expose them with the AttributeExposer if necessary.
It's a basic solution, but if a feature may have two or more same tags (attribute names after renaming), it will be more complicated.
Is there such a situation? e.g. a feature may have two or more "highway" tags?
I think that the features (after the ListExploder) having same ID have same geometry, since the geometry of each original feature has been cloned through the ListExploder. So I'm afraid that duplicate geometries will be aggregated if you set "Geometry-Assemble One Level" to the parameter.
Check if the resulting geometries are properly.
If they have duplicate geometries, there are at least two ways to resolve that.
In both cases, set "Attributes Only" to the "Mode" parameter of the Aggregator. And optionally you can remove geometry before the ListExploder.
1. Merge the extracted attributes to original feature.
Add a FeatureMerger; send the original features (having geometry) to the Requestor port; send the aggregate features (having extracted attributes) to the Supplier port; join them on "id".
I verified the output and I confirm there are no geometry duplicates found..for curiousity, I also implemented both of the cenarios you mentioned above, and they produced the same reults and the output has no geometry duplicate as well.