Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to make a plugin for Qgis with python. I have the four corner coordinates for a rectangle. I want to give the user the inputs, line space and angle (0 -180 degrees).

With these inputs, I want to fill this rectangle with lines in the direction of the specified angle and with the specified line spacing between the lines.

I guess what I need is the same type of code as for making a grid. But I can only find information about grids which are vertical or horizontal. I will try to code it myself, but if anyone have a webpage with information, I would gladly to read it.

share|improve this question

1 Answer 1

Here is how I would proceed

1. Get the slope of the lines

I am not sure of the lines between which is the angle.

If between the line and the x axis: formula1

If between the origin and a given point: formula2

2. Get the parametric equation of the lines

This can be achieved with the traditional line equation formula3 or with the point-slope equation formula4. In both case, this (the origin b or the point) will be obtained based on the spacing between the lines.

3. Create the segment

With the equation of each line, we can create a segment contained withing the rectangle. For this step, I would use the functions in the shapely library (union, intersection,...)

4. Export that in whatever format

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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