Skip to main content
Question

combine list in one point shapefile

  • May 9, 2019
  • 11 replies
  • 24 views

a_afiaax
Contributor
Forum|alt.badge.img+2

Hello FME community,

I am quite a beginner with FME and I have point shapefile includes country names. Each country name divided into 2 parts and the 1st part ended with (-).

How can I combine a country name and remove (-) in the following list?

To this:

For each name sometimes 1st part sorted at end, for example Camb-

Does anyone have any ideas or potential solutions?

@takashi @david_r @jlutherthomas @egomm @mark2atsafe

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.

11 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • May 9, 2019

Hello @a_afiaax

I simulated here your case with the XLS Reader.

First: filter by attribute Name with symbol " - " - transformer StringSearcher.

Step 2: Create a attribute Order for each results from Output port Matched ( transformer StringSearcher ).

Step 3: Sroter by attribute Order and after Aggregator by attribute Point_ID.

 

Attached the Workspace Template - Workspace_String.fmwt

 

Thanks,

Danilo


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • May 9, 2019

So the general approach would be PointOnPointOverlayer to build the list, ListConcatenator to join the name values and then a StringReplacer to get the - out. But you need to make sure the list is sorted correctly, either by making sure the points enter the PointOnPointOverlayer in the correct order or by sorting it before the ListConcatenator. Otherwise you'd might end up with odiaCamb-

So I've added an extra sorting attribute, that's being filled with a conditional value: if Name ends in a - it's the first part, so it gets a 1, the rest must be the second part so it gets a 2.

And the entire workflow:

Note that this may produce strange results if the name of the country contains hyphens


a_afiaax
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • 9 replies
  • May 9, 2019

Hello @a_afiaax

I simulated here your case with the XLS Reader.

First: filter by attribute Name with symbol " - " - transformer StringSearcher.

Step 2: Create a attribute Order for each results from Output port Matched ( transformer StringSearcher ).

Step 3: Sroter by attribute Order and after Aggregator by attribute Point_ID.

 

Attached the Workspace Template - Workspace_String.fmwt

 

Thanks,

Danilo

Hello Danilo,

1st AttrributeMangaer includes 2 attributes i cant understand them !.

 

The final result looks nice but missed 2 records (ID:10Z and ID:14B):

 

Do you have any idea to keep all IDs?

Thank you.


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • May 9, 2019

So the general approach would be PointOnPointOverlayer to build the list, ListConcatenator to join the name values and then a StringReplacer to get the - out. But you need to make sure the list is sorted correctly, either by making sure the points enter the PointOnPointOverlayer in the correct order or by sorting it before the ListConcatenator. Otherwise you'd might end up with odiaCamb-

So I've added an extra sorting attribute, that's being filled with a conditional value: if Name ends in a - it's the first part, so it gets a 1, the rest must be the second part so it gets a 2.

And the entire workflow:

Note that this may produce strange results if the name of the country contains hyphens

PointOnPointOverlayer? Do you need to do it spatially if there is an ID for the key?


a_afiaax
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • 9 replies
  • May 9, 2019

So the general approach would be PointOnPointOverlayer to build the list, ListConcatenator to join the name values and then a StringReplacer to get the - out. But you need to make sure the list is sorted correctly, either by making sure the points enter the PointOnPointOverlayer in the correct order or by sorting it before the ListConcatenator. Otherwise you'd might end up with odiaCamb-

So I've added an extra sorting attribute, that's being filled with a conditional value: if Name ends in a - it's the first part, so it gets a 1, the rest must be the second part so it gets a 2.

And the entire workflow:

Note that this may produce strange results if the name of the country contains hyphens

Hi @redgeographics , it end up with odiaCamb :

 

In addition to missing 2 record and 2 attributes (ID and Name):


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • May 9, 2019

I'd create the combined names by aggregating based on the Point_ID after ordering and then merge them back to get the output required

Combine_part_string.fmwt

 

 


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • May 9, 2019

Assuming the points are ordered so that the pairs are together (regardless of internal order), this can be done with a single AttributeCreator using adjacent feature handling and conditionals.

 

 

adjacentstring.fmwt

jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • May 9, 2019

Assuming the points are ordered so that the pairs are together (regardless of internal order), this can be done with a single AttributeCreator using adjacent feature handling and conditionals.

 

 

adjacentstring.fmwt

If the assumption is incorrect, then a sorter on Point_ID prior to the attributeCreator would do the trick.


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • May 9, 2019

PointOnPointOverlayer? Do you need to do it spatially if there is an ID for the key?

Not really (but hey, I'm a spatial person)


redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3701 replies
  • May 9, 2019

Hi @redgeographics , it end up with odiaCamb :

 

In addition to missing 2 record and 2 attributes (ID and Name):

Did you set the AttributeManager and Sorter up like the example?


a_afiaax
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • 9 replies
  • May 10, 2019

Assuming the points are ordered so that the pairs are together (regardless of internal order), this can be done with a single AttributeCreator using adjacent feature handling and conditionals.

 

 

adjacentstring.fmwt

Hi @jdh

Thank you for this solution. It takes little pit to understand conditions but it amazing.