5

I've got a square origin-destination matrix with 23 elements, I would like to draw each one of these elements as a point around a circle, to achieve a result like the following:

enter image description here

Can you suggest me a fast method to draw points around a circle?

I'm doing the following but doesn't works:

1) set central point

2) create a buffer with segments=99 and distance=50, uncheck "dissolve the result" option enter image description here

3) convert shape to line, I get 99 lines enter image description here

4) calculate the line length/23 enter image description here

5) convert line to points, set "insert additional points" to "No", use the result of line length/23 (1316383,260) in "distance" field enter image description here

What I get is 396 points where the lines touch each other’s:

enter image description here

0

2 Answers 2

5

Never used matrices so I could be wrong. But I would create a buffer from a central point (which you can add manually) and use the radius of a circle (I'm assuming the radius is the same for all of them otherwise you may have to create more buffer layers). When buffering, set the segments to approximate to 99 to have a smoother perimeter:

Point and buffer

You can then use Convert polygons to lines on the buffer layer.

Polygon to line

And with the output, use Convert lines to points (both tools are from SAGA via the Processing Toolbox). This should give you a point layer which lies on the circumference of the circle.

Line to points

Hope this helps.


EDIT:

When you use Convert polygon to lines, calculate the length of line via the Field Calculator by creating a new column (select Decimal numbers) and inserting this into the expression:

$length / 23

This will give the same length for each "segment".

Now when you run the Convert lines to points function, input the length you received into the Insert Distance field. This will produce a 23 points at the same length:

23 points


Alternative method:

Take your final Step 5 layer (with the 396 points) and open up the Attribute Table and Field Calculator. Create a new integer column (eg. RowNum) and insert this expression:

$rownum

This provides each field with a unique value. Next, select the Advanced Filter (Expression) at the bottom of the Attribute Table:

Select Advanced Filter

And enter this command (replace "RowNum" with your named column):

("RowNum") %17

This expression skips every 17th field (396/23 = 17, we want to keep every 17th field). Select ALL those fields shown and DELETE them. Then select the Show All Features at the bottom of the Attribute Table. You should now (let's all pray!) have 23 points. Remember to also save!

10
  • thanks for your help @Joseph, I'm trying to have 23 points equally distanced from the center and from each other, but if in the buffer option I write 23 in the segment section I don't get 23 segments... any suggestion? Commented Nov 11, 2014 at 15:18
  • Hi Matteo, do you need these points as actual data points or are you using it for visualisation?
    – Joseph
    Commented Nov 11, 2014 at 15:38
  • I'm using these to visualize connection between them in a circular layout, so I might say for visualization, but I'm not sure about what do you mean with "data points". I will need to merge attributes on each points though. Commented Nov 11, 2014 at 15:41
  • Thanks Matteo, yes I meant if you need to perform analytical operations with them. Edited the post.
    – Joseph
    Commented Nov 11, 2014 at 15:56
  • mmmmhhh I don't know what I'm doing wrong: Commented Nov 11, 2014 at 16:15
3

I think this may create the points you need, in a simpler manner (I used a spreadsheet, because it is easier, but this could be done inside QGIS, too:

a) You want "n" points, in your case, 23. Calculate the value of 2*pi/n. This is the angle between each of your points [ "angle" ]

b) Create a column ["ID"] with the numbers 1 to n ; n=23 in your case

c) in the next two columns, save the results of this expression:
sin( angle * (ID-1)); The first ID is really at 0 degrees
cos( angle * (ID-1))
These are the x-y coordinates of all your points

d) Create 2 more columns. These will be the other endpoints for line segments. Insert all the values from the first two columns, but shift down one row: Row 2 for this pair of columns contains the values for Row 1 in the first pair of columns.

e) for row 1, of this second pair, place the value of row n (23) of the first column

You now have 5 columns:
First column is the point ID
Columns 2-3 and Columns 4-5 represent the line segments

So, now you have: points, line segments, or a polygon, depending on what you do with the data.

I crafted a spreadsheet to do this in about 2 minutes. If I were using it, I would export the excel spreadsheet to CSV or somesuch, and import as needed, that is, into points, lines or a polygon.

If I figure out how to import a spreadsheet, here, or post an image at least of it, I will.

1
  • Importing CSV data as point coordinates is an easy task for QGIS with "Add delimited text" using the icon with the comma symbol. Lines can be imported if you have a column formatted as WKT: gis.stackexchange.com/questions/34342/…
    – AndreJ
    Commented Nov 12, 2014 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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