3

I'm attempting to calculate the radii required to cover a set of polygons in a shapefile; for example, given any number of neighborhood polygon boundaries, I'd like to calculate the smallest circle radius required to cover each.

Is there a way to calculate a minimum bounding circle in QGIS, given a polygon? Otherwise, is there a way to do so in python?

Edit: I'm using QGIS 2.18 on MacOS.

  • Do you have access to QGIS 3.0 (2.99)? - Minimum bounding geometry tool. – Kazuhito Feb 13 '18 at 22:23
  • @Kazuhito I'm running QGIS 2.18 on MacOS. Do you know if it's possible to install 2.99? I've always used KyngChaos' ports, and the latest seems to be 2.18. – scrollex Feb 13 '18 at 22:27
3

Sorry, only thing I can think of, with QGIS 2.18, is geometry generator.

Assuming you have convex hull polygons for each set of polygons;

buffer(point_on_surface($geometry), 
       max(bounds_height(bounds($geometry))/2,
           bounds_width(bounds($geometry))/2)) 

This takes maximum distance from centroid (*) of each convex hull to create a circle.

(*) I used point_on_surface in lieu of centroid.

If you want it permanent (I mean, not only for display), please run the same expression in the Field Calculator using the Update existing field on <geometry> column.

| improve this answer | |
4

QGIS 3.0 (or 2.99) can calculate this directly, using either the "Minimum enclosing circles" (for a circle for each individual feature) or the "Minimum Bounding Geometry" algorithm with "geometry type" as "minimum enclosing circle" (for the entire layer at once)

| improve this answer | |
3

If you have access to PostGIS you have a function called ST_MinimumBoundingCircle. With SQL you can fit it to run on a single feature, several features controlled by an attribute, or on all the features of the entire layer.

https://postgis.net/docs/ST_MinimumBoundingCircle.html

Four demo polygons:

enter image description here

SELECT 
  row_number() OVER() AS id,
  ST_MinimumBoundingCircle(geom) As geom
FROM 
  sandbox.poly;

Gives one circle for each polygon:

enter image description here

And:

SELECT 
  row_number() OVER() AS id,
  type,
  ST_MinimumBoundingCircle(ST_Collect(geom)) As geom
FROM 
  sandbox.poly
GROUP BY  
  type;

Gives a circle based on the type attribute:

enter image description here

The line:

row_number() OVER() AS id

Is for QGIS to have an unique integer column for rendering the layer.

Demo made with DB Manager plugin for QGIS.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.