Skip to main content

Hi,

I have a shapefile with municipality polygons and I am using the SpatialRelator with the option "Requestor Touches Supplier" to count the number of neighbours of each polygon. However, I need to know the lenght of each common border for all polygons. Is there a way to output that information? In QGIS is posible (as explained on this link https://spatialthoughts.com/2020/04/08/calculating-shared-border-lengths/#more-962 ) but it's not very fast to run, therefore I would like to do the same in FME.

Thanks and best regards

Oscar

** Updated - Added ListConcatenator and group by _concatenated in the Aggregator to fix incorrect group by **

 

Chop to create lines, overlay lines to build a list of intersecting lines, test out the overlapping lines, concatenate unique ID from list, explode into features, aggregate by unique value, and calculate length.

 

See attached fmwt.

 

Example for Kansas and Oklahoma;

 


Dear @jlbaker2779 , thank you very much for your answer.

I tested your flow without the first TESTER, trying to make it more general, but I am probably missing something because I obtain the length of the border between (for example) Texas and all its neighbours and what I need is the length of the border between Texas and New Mexico, Texas and Oklahoma, Texas and Arkansas, and so on, and this for every single State (in my case, every parcel of the municipality I am studying).

Kind regards,

Oscar


If you need two lines for each shared border, one for each side, i'd try something like this

Shared_Border_Length.fmwt


I would approach it differently using the TopologyBuilder. The attached workspace creates a list on the polygons with the name and shared length of the adjoining polygons.

 

 

Caveats: aggregates are separated into their component parts. If an adjoining polygon has multiple disconnected common borders, then each one is in the list independently.

 

 

The second issue I would handle by creating a summed histogram. The first issue I would have to think about how to merge the lists when aggregating, but that's more investment than I have time to do this lunch break.

 

 

commonborder.fmwt

Dear @jlbaker2779 , thank you very much for your answer.

I tested your flow without the first TESTER, trying to make it more general, but I am probably missing something because I obtain the length of the border between (for example) Texas and all its neighbours and what I need is the length of the border between Texas and New Mexico, Texas and Oklahoma, Texas and Arkansas, and so on, and this for every single State (in my case, every parcel of the municipality I am studying).

Kind regards,

Oscar

Updated my original post with a slight change. I forgot to concatenate the name in the list for the group by in the aggregator.


Dear @ebygomm, @jlbaker2779 and @jdh, all codes produce usefull results, thank your very much for your help, I really appreciate it

Best regards,

Oscar


Can we please take a moment to appreciate persons like @jlbaker2779​  who share their knowlegde altruisticly? Is a great and easy way to improve your own FME skills. Thanks.


Reply