# Midline through rectangular polygon

I want to be able to extract two sets of coordinates which are the midpoints of two shorter sides of a rectangular polygon (purple points).

I know there is an intersection tool in QGIS which can get me those, however I can't figure out how to automatically generate the midlines which are used in the intersection tool. Is there a way of doing that in QGIS/GRASS? I would like to automate the process as much as possible so manual line creation is not an option. • Welcome to GIS SE! A question asking for help with code should include a snippet of the code you've actually tried, and details of what happens when you try it. Please edit your question to include your code snippet and any error message. – Midavalo Dec 17 '17 at 16:24
• I think that the question is OK. I do not know if there is a tool for the task in QGIS but I know another open source GIS software that has such tool. First part of the process would probably be to skeletonize the polygon gis.stackexchange.com/questions/171145/…. – user30184 Dec 17 '17 at 21:00

## 2 Answers

If you only want the coordinates of the points you indicated you don't need to generate the lines... you just have to calculate their coordinates using the four vertices of your rectangles.

You take the two shortest segments of your rectangle and then calculate their midpoints.

The answer to this question: Dividing a trapezium into quarters with QGIS? solved a problem on how to create a mid point along lines and divide the polygon into quarters. You can apply the same code to divide the polygon into two halves. However, creating mid point will be automatically, but dividing the polygon will be manually.

Following the steps in the above answer, you can create a mild point at each polyline. Divide the polygon using the mid located at the shortest lines using divide tool: Turning off the point layer and save the edits: 