0

I'm writing code in grass and i need to calculate this two variables:

  • the length of the longest axis in the units of the Spatial Reference of the input feature class.
  • the length of shortest side of the bounding rectangle aligned with the longest axis in the units of the Spatial Reference of the input feature class.

Like the example

Example

I have lots of shape-files and i need that characteristics:

I try with this code in grass

v.in.ogr = ...
v.to.db map=* option=length 

but in that case perimeter and length are exactly the same.

I except the output like the figure, two numbers for each shape.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0

You can use v.to.points to calculate vertexs that make up the polygon, then use v.distance to obtain the distances between the vertexs and finally obtain the maximum distance with GRASS or SQL sentence, thus obtaining the length.

With that it is already easy to build the bbox and get the width.

v.to.points --overwrite input=envol type=area output=points use=vertex
v.distance -a --overwrite from=points from_type=point to=points to_type=point upload=dist

I hope it helps you.

deiviiz
  • 1
  • 1