Skip to main content
added 785 characters in body
Source Link
Babel
  • 80.4k
  • 15
  • 97
  • 245

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression as you already have a field angle in your data that, depending on which one is the longest side, can be used to create what you want:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

If you want to get the mean value for the angle (azimuth) of all these lines, create a new layer centerline using Geometry by expression with the expression from above. On this line layer, create a new field azimuth using field calculator that calculates the angle of each line with this expression:

degrees ( azimuth ( start_point ($geometry), end_point ($geometry) ) ) 

Now, you can use Menu Vector / Analysis tools / Basic statistics for fields on the centerline layer and setting the field azimuth as input (see screenshot below). The mean value for all centerlines, calculated with your data and according to this tool is 39.470817687074835.

enter image description here

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression as you already have a field angle in your data that, depending on which one is the longest side, can be used to create what you want:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression as you already have a field angle in your data that, depending on which one is the longest side, can be used to create what you want:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

If you want to get the mean value for the angle (azimuth) of all these lines, create a new layer centerline using Geometry by expression with the expression from above. On this line layer, create a new field azimuth using field calculator that calculates the angle of each line with this expression:

degrees ( azimuth ( start_point ($geometry), end_point ($geometry) ) ) 

Now, you can use Menu Vector / Analysis tools / Basic statistics for fields on the centerline layer and setting the field azimuth as input (see screenshot below). The mean value for all centerlines, calculated with your data and according to this tool is 39.470817687074835.

enter image description here

added 135 characters in body
Source Link
Babel
  • 80.4k
  • 15
  • 97
  • 245

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression as you already have a field angle in your data that, depending on which one is the longest side, can be used to create what you want:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression as you already have a field angle in your data that, depending on which one is the longest side, can be used to create what you want:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here

Source Link
Babel
  • 80.4k
  • 15
  • 97
  • 245

I inspected your data, the solution is based on that. First, create a new field longest that evaluates which side of your rectangle is the longest, width or height. Use this expression in the field calculator: if ( "width" > "height" , 'width', 'height').

Than you can create the centerline using this expression with Geometry generator or Geometry by expression:

intersection ( $geometry, extend ( make_line ( centroid ($geometry), project ( centroid ( $geometry ), 20, if ( "longest" = 'width' , radians ("angle"-90 ), radians ("angle" ) ) ) ), 20, 0 ) ) 

enter image description here