Skip to main content
Question

combine list in one point shapefile


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

11 replies

danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • 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+50

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
  • May 9, 2019
danilo_fme wrote:

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+44
redgeographics wrote:

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
  • May 9, 2019
redgeographics wrote:

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+39
  • Influencer
  • 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+28
  • Contributor
  • 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+28
  • Contributor
  • May 9, 2019
jdh wrote:

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+50
mark2atsafe wrote:

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+50
a_afiaax wrote:

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
  • May 10, 2019
jdh wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings