Notice how the answer is not quite correct even though accepted.
Source Link
Gabriel
  • 2.8k
  • 9
  • 28

Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle or if the vertices defining the circle are adjacent, the values can differ. I left it there as it provides an answer for a similar problem but even I agree it should not be the accepted answer.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle, the values can differ. I left it there as it provides an answer for a similar problem but even I agree it should not be the accepted answer.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle or if the vertices defining the circle are adjacent, the values can differ. I left it there as it provides an answer for a similar problem but even I agree it should not be the accepted answer.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

Notice how the answer is not quite correct even though accepted.
Source Link
Gabriel
  • 2.8k
  • 9
  • 28

Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle, the values can differ. I left it there as it provides an answer for a similar problem but even I agree it should not be the accepted answer.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

Bear in mind that someone correctly pointed out very soon in comments that I had misread the question. My answer gives the diameter of the minimal circle but this does not always correspond to the longest distance between vertices in a polygon. As soon as more than 2 vertices touch the circle, the values can differ. I left it there as it provides an answer for a similar problem but even I agree it should not be the accepted answer.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

slight error in the expression
Source Link
Gabriel
  • 2.8k
  • 9
  • 28

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n($geometry,1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

It is possible to do with simple expressions in the field calculator (at least in QGIS 3.12.x). Take for example these two polygons. The symbology shows four things (using the geometry generator, for explanation purposes):

  • Red outline of the true polygon
  • Semi-transparent orange circle resulting from the minimal_circle() function
  • Blue point resulting from the centroid() function of the minimal circle
  • White point resulting from the point_n() function of the minimal circle's first vertex

enter image description here

So to get the diameter of the minimal circle containing the polygon, go to the field calculator and use this expression in a new decimal field:

distance(centroid(minimal_circle($geometry)),point_n(minimal_circle($geometry),1)) * 2

This will calculate the distance between the centroid and the first vertex along the circle (the radius), then multiply it by two.

typo
Source Link
Gabriel
  • 2.8k
  • 9
  • 28
Loading
Added version of QGIS used.
Source Link
Gabriel
  • 2.8k
  • 9
  • 28
Loading
Source Link
Gabriel
  • 2.8k
  • 9
  • 28
Loading