Question

Extract the highest value

  • 25 April 2014
  • 5 replies
  • 7 views

Hi,

 

 

I have lines in shp representing buildings. Each line of the building has its own attributes, such as line type (in pic value 1,2,3...). In the same places, there are polygons that have no attributes. I need to find lines that overlap with polygons, but to take the line with the highest value of "type of line" and transfer all attributes from that line to polygon. In pic so,first upper polygon should have a value of 1, right polygon value 2, left 3, and the bottom 2.

5 replies

Userlevel 2
Badge +17
Hi,

 

 

I would use the SpatialRelator, ListSorter and ListIndexcer.

 

 

Send polygons to Requestor (BASE), lines to Supplier (CANDIDATE) of the SpatialRelator. Output features are polygons, and each of them will have a list attribute (named "_relationships{}" by default) containing all attributes of spatially related lines.

 

The list is a structured one. If lines have an attribute called "line_type" for the type of line, output polygons will have "_relationships{}.line_type".

 

 

Next, sort the list with the ListSorter so that the first element is the largest line type.

 

List Attribute: _relationships{}.line_type

 

Sorting Type: Numeric

 

Sorting Order: Decreasing

 

 

And then, extract the first element of the list with the ListIndexcer.

 

List Attribute: _relationships{}

 

List Index: 0

 

 

Hope this helps.

 

 

Takashi
Badge
Another idea that parallels Takashi's would be to user a sorter, descending numerically by "type of line." 

 

 

Then use a duplicate remover and the set the "Key Attribute" as the unique ID that defines each set of lines. Note, if there are no key attributes, then the Sorter and DuplicateRemover can be set after the ListExploder.

 

 

Back to the first workflow, send the data to a LineOnAreaOverlayer, name the list, and then send the "Area Output" onto a ListExploder. Explode the list by the name you previously gave the list. Now your polygon will have the attributes of the highest value "type of line."

 

 

 

 

or the second method

 

 

 

Hi,

 

 

thanks for your reply..i have another problem..two ore more polygons have the same line with the highest value..how to assign the value 7 both polygons?

 

Userlevel 2
Badge +17
I think the SpacialRelator approach I suggested should work also in that case.
Badge +3
LineOnAreaoverlayer with a listname. Listrangeextractor on Areaoutput. (Ditch the _min.)

Reply