Question

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

  • 19 September 2022
  • 7 replies
  • 1 view

Badge

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

Userlevel 3
Badge +26

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

Userlevel 3
Badge +26

Here is the workbench:

Badge

Thank you, this is very useful!!

Badge

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

 

Userlevel 3
Badge +26

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

Badge

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

Userlevel 3
Badge +26

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

Reply