Skip to main content
Question

I want to provide lines (waterway) with the code of the polygon (neighborhood) it runs through.

  • September 19, 2022
  • 7 replies
  • 19 views

Forum|alt.badge.img

Hello everyone,

 

I have a shapefile with polygons (neighborhoods) and a shapefile with lines (waterways). Each polygon has a specific code attached to it. I want to provide each line with the code of the polygon it runs through. When the line runs through several polygons, it must get the code of the polygon through which the line runs the longest. 

 

Does anyone know how I can best handle this?

 

Regards Bas

 

7 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • September 19, 2022

The attached workbench should give you the desired results. To sum it up:

  • Archive the original geometry of the lines
  • Split the lines per the polygons, which merges the code onto the lines
  • Calculate the length, and find the max length
  • Test for length equaling the max length, keeping those.
  • Replace the geometry with the archived original geometry.

(If you already have a unique ID on the lines, you can use that instead of creating one in the Counter transformer. You will just need to update the StatisticsCalculator to your unique ID.)

 

image


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • September 19, 2022

Here is the workbench:


Forum|alt.badge.img
  • Author
  • 7 replies
  • September 21, 2022

Thank you, this is very useful!!


Forum|alt.badge.img
  • Author
  • 7 replies
  • October 5, 2022

Hello @dustin​ ,

 

I have a few questions about the workbench:

 

do I have to add 1 file geodatabase to the reader where the polygons and the lines are located?

do you have the parameters for the LengthCalculator? I had to re-add this.

where can I find my output data? Because there is no writer.

 

thanks in advance,

 

Bas

 


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • October 5, 2022

@bascopier​ Yes. You will need to add your geodatabase reader feature types, feeding your lines and polygons as I did my test data. The LengthCalculator used the default settings (_length). You will need to add a writer for the format you are wanting to write to, which will go right after the GeometryReplacer (instead of the Inspector I was using for testing)


Forum|alt.badge.img
  • Author
  • 7 replies
  • October 5, 2022

@dustin​ so i have 1 geodatabase that includes the lines ánd the polygons and use this for both readers (lines and polygons).


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • October 5, 2022

When you read in the geodatabase, it will read in both the line and polygon feature classes (whatever your feature classes are named, not necessarily 'line' and 'polygon'). The lines would be fed into the Counter, polygons would be fed into the area port of the LineonAreaOverlayer.image