Skip to main content

(I asked this question in here,

https://knowledge.safe.com/questions/1935/distance-between-points.html?childToView=64766#answer-64766

but I figured I probably needed to make a separate new post, since it involves a different set of issues.)

I need to calculate the distance from each point feature in a point dataset to each polygon feature in another dataset. I've used the neighbourfinder with the maximum distance set in such a way that it will include all the features involved.

I also set the number of neighbours to the amount of polygon features I have.

I set the list name.

After that I used a list exploder to get a list of all the distances from each point to each polygon. That seems to do the job. However, how do I now transpose the list?

I get a table with the amount of records equal to the number of point features multiplied by the numer of polygon features. I want a table with the same amount of records as the point featurues, and added to it the distance to each polygon feature in separate columns, preferable with the new columns automatically named after an "id attribute" in the polygon dataset.

How do I do that? Or maybe there's another transformer that does the trick?

@takashi

Could you please post an example illustrating the tables before and after 'transposing'?

 

 


Hi @fmenco, thanks for posting the example.

This BulkAttributeRenamer renames every "distance" to "distance to polygonID<PolygonID>". You can then aggregate the records for each Point ID.

Note: FME (Engine) can rename an attribute name according to an attribute value at run-time but FME Workbench cannot automatically expose attribute names which will be renamed at run-time, so you have to expose the attribute names ("distance to polygonID1", "distance to polygonID2", ...) manually with AttributeExposer, if necessary.


Hi @fmenco, thanks for posting the example.

This BulkAttributeRenamer renames every "distance" to "distance to polygonID<PolygonID>". You can then aggregate the records for each Point ID.

Note: FME (Engine) can rename an attribute name according to an attribute value at run-time but FME Workbench cannot automatically expose attribute names which will be renamed at run-time, so you have to expose the attribute names ("distance to polygonID1", "distance to polygonID2", ...) manually with AttributeExposer, if necessary.

Thanks, I've tested this. But maybe I made a mistake in the sequence for the transformers?Because the records for the additional attributes are empty.

 

@takashi

 


Hi @fmenco, thanks for posting the example.

This BulkAttributeRenamer renames every "distance" to "distance to polygonID<PolygonID>". You can then aggregate the records for each Point ID.

Note: FME (Engine) can rename an attribute name according to an attribute value at run-time but FME Workbench cannot automatically expose attribute names which will be renamed at run-time, so you have to expose the attribute names ("distance to polygonID1", "distance to polygonID2", ...) manually with AttributeExposer, if necessary.

Check this demonstration: bulkattributerenamer-aggregator.fmwt (FME 2017.1.2)

 

 


Check this demonstration: bulkattributerenamer-aggregator.fmwt (FME 2017.1.2)

 

 

Yes, that's what I did. I think it works...The field aren't empty, I forgot to merge incoming attributes, I think..

 

This seems to do the trick. Thank you !

 


Check this demonstration: bulkattributerenamer-aggregator.fmwt (FME 2017.1.2)

 

 

............

 


Check this demonstration: bulkattributerenamer-aggregator.fmwt (FME 2017.1.2)

 

 

 

@takashi Upon closer inspection. This doesn't work...For every newly created column the information is the same. I think you need to xplicitely name the listindex you want use. Now it seems FMe only usus the same listindex for every attribute column. (I've also used the neighborfinder instead of the inlinequerier... is that the problem?

 

@takashi Upon closer inspection. This doesn't work...For every newly created column the information is the same. I think you need to xplicitely name the listindex you want use. Now it seems FMe only usus the same listindex for every attribute column. (I've also used the neighborfinder instead of the inlinequerier... is that the problem?
There is no list operation in my demonstration. What are you talking about?

 

 


There is no list operation in my demonstration. What are you talking about?

 

 

 

Yes, my apologies. I see now. I made a mistake. I'm going to test your template again

 


There is no list operation in my demonstration. What are you talking about?

 

 

I tested, I changed my workbench to fit your template. And it doesn't work.

 

yes, it creates the extra attributes like I wanted. But the fields are all empty.

 

Sorry, if I'm asking silly questions..:-)

 

Edited: Is the expression used to calculate the "distance" correct?

 

 


I tested, I changed my workbench to fit your template. And it doesn't work.

 

yes, it creates the extra attributes like I wanted. But the fields are all empty.

 

Sorry, if I'm asking silly questions..:-)

 

Edited: Is the expression used to calculate the "distance" correct?

 

 

The expression to calculate 'distance' in my template is just for testing the following workflow. The values have no meaning.

 

 


There is no list operation in my demonstration. What are you talking about?

 

 

I'm sorry..., I'm not that familiar with coding... how in this workbench am I supposed to get the distance between the features?

 

 


There is no list operation in my demonstration. What are you talking about?

 

 

I suppose the distance is given by the NeighborFinder in your actual workspace.

 

 


I suppose the distance is given by the NeighborFinder in your actual workspace.

 

 

 

Yes, but the distance in the neighbourfinder is a list. I've managed to get/expose each distance from point to polygon through the attributemanager. However, i just need to write those values to the right polygon id, because now I don't know what polygonid list{0}.distance etc refers to.

 


There is no list operation in my demonstration. What are you talking about?

 

 

I think you can use the ListExploder to create features each of which contains attributes (polygon ID etc.) from a polygon and 'distance' given by the NeighborFinder.

 

 


I think you can use the ListExploder to create features each of which contains attributes (polygon ID etc.) from a polygon and 'distance' given by the NeighborFinder.

 

 

But then I'm back at square one, right? That's what I did in the beginning. I used a neighborfinder, a list exploder...But then I ended up with the tables I posted as an example.

 

 

I've managed to expose the list.distance{} for each index after the neighborfinder. (with the attributemanager, clicked te dropped down buttonfor the output, rigghtclicked on the list and clicked exposed for all the indices). Now I just need to find a way to rename those columns correctly.There has to be a script for it. I've ried every "list" transformer . None of them seem to do the job...

 

 


There is no list operation in my demonstration. What are you talking about?

 

 

The NeighborFinder and the ListExploder worked just fine. See the attached demo.

 

distance-between-point-and-polygon.fmwt (FME 2017.1.2.1)

 

 


YES!! This works.... Thank you so so much for you guidance and patience...:-)


Reply