Question

combine list in one point shapefile


Badge +1

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

Userlevel 4
Badge +30

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

Userlevel 5
Badge +25

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

Badge +1

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.

Userlevel 4
Badge +25

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?

Badge +1

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):

Userlevel 1
Badge +21

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

 

 

Badge +22

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
Badge +22

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.

Userlevel 5
Badge +25

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)

Userlevel 5
Badge +25

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?

Badge +1

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.

Reply