TransWikia.com

How do I use Join Attribute by nearest in this case, to avoid referencing an algorithm output in field calculator expression?

Geographic Information Systems Asked by hadallen on June 27, 2021

I have a model that I have built to automate the process of assessing wind hazard on forested edges.

Currently I can run it successfully but:

  • I have to run it once, create the Test layer, and then run it a second time for Offset_Azimuth Calc to complete
  • Offset_Azimuth Calc expression like so: (referencing the ‘Test’ layer)
degrees( 
    with_variable( 
        'line',
        shortest_line (
            centroid (
                array_first( 
                    overlay_nearest( 
                        'Test', 
                        $geometry
                    )
                )
            ), 
            $geometry
        ),
        azimuth (
            start_point (@line),
            end_point (@line)
        )
    )
)

Model example


I have tried the following, but I think I must be misunderstanding something here – I think it should easier than I am making it.

  • Separate the model into two, a "prep" model that explodes the lines and assigns azimuth to each segment, and an "assessment" model that has Exploded_Boundary as an input (from prep) and referencing the "Exploded_Boundary" layer within the offset_azimuth calc expression. This will only work if the layer from prep is saved accordingly, and is less ideal for sharing with coworkers.

I have been unsuccessful in my attempt of making it a single model with 2 inputs, and 1 output (wind_hazard). I have tried using Wind_Hazard_Prep within the second Assessment model, but that did not work either – I could not reference the Wind_Hazard_Prep output from within the Offset_Azimuth Calc expression.

I see that there is a workaround by using Join Attribute by nearest, but I cannot figure out how to add and calculate the offset_azimuth field with it, as the problem here is that I cannot reference the exploded lines layer and the Intersection_OUTPUT (point layer) at the same time

Separating Models

One Answer

Working Model:

Working Single Model

I likely have this more complicated than it needs to be, but it's working. To get around the geometry type difference (line segments and points), I interpolated midpoints and merged them together, then used field calculator to calculate the offset_azimuth as desired.

Now this model works, take a single boundary layer input and wind direction. Some tweaking as I have already discovered an issue if I use a windDir higher than 315 or lower than 45. Feel free to answer with a more appropriate solution

Correct answer by hadallen on June 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP