5

Trying to offset a line by 10 degrees, rotating around an endpoint. I've read up on the older plugins and the new Rotate Feature tool, but am having trouble. I am using QGIS 2.8.9 Wien, reinstalled just a few weeks ago.

  • The Rotate Feature(s) tool allows me to rotate a line around a rotation point (which I know how to move), but I can't find any way to enter a specified rotation angle, or even to see what my angle would be. I've read things that make me think it may have once been there, but can't find anything that says how to use it or if it can still work this way.
  • I installed CadTools and have tried using it, but keep getting errors: An error has occurred while executing Python code:
    Traceback (most recent call last):
    File "C:/Users/bhughes/.qgis2/python/plugins\cadtools\tools\rotateobjecttool.py", line 75, in rotateObject geom = cadutils.rotate(self.feat.geometry(), self.pl,    angle • math.pi / 180)
    File "C:/Users/bhughes/.qgisZ/python/plugins\cadtools\tools\cadutils.py", line 127, in rotate p1 = QgsPoint(i.x() - point.x(),  i.y() - point.y())
    Attribute Error: 'NoneType' object has no attribute 'x'

Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

QGIS version: 2.8.9·Wien Wien, 26c3ece

attribute x It tells me that the CRS is undefined and that it's defaulting to WGS84, but ALL of my layers are defined as EPSG 102640, and so is my project CRS. I've even got OTF turned off until the CadTools creates a CadLayer temporary layer in WGS84.
If I create a project in WGS84, the tool gives me the same error, but it will draw a line that I can save. I got it to work once in 102640, but couldn't save the line; haven't been able to recreate it. I don't want WGS84!

This is addressed on the hub under Feature Request #1787 and Feature Request #3472. They both mention rotating by an angle; sounds like a window is supposed to just magically appear...

Am I the only one who can't make it work? Am I stuck in a WGS84 world?

1
  • 1
    Please replace your picture of an error message with the text of that error message so that it can be read more easily and is available to future searches.
    – PolyGeo
    Sep 15, 2016 at 4:08

1 Answer 1

1

Use QGIS expressions with either Geometry generator (for visualization) or Geometry by expression (for actual geometries, see also here for differences between these two tools) to create a rotated line. Use this expression:

rotate( 
    $geometry, 
    10,
    end_point($geometry)
)

Explanation:

  • line 2: the geometry to rotate: the current geometry
  • line 3: degrees clockwise
  • line 4: rotation center point: end-point of current geometry

Screenshot: layer in CRS 102640 with initial line (black), rotated lien (red), created with Geometry generator: enter image description here

By the way: using generate_series, you can loop and create different rotation angles at once, e.g. in 10-degrees intervals:

collect_geometries (array_foreach(
    generate_series(0,360,10),
        rotate( 
        $geometry,
        @element, 
        end_point($geometry) 
    )))

Screenshot: the same line from above, rotated with 10-degrees intevals: enter image description here

Using the same principle, you can very easily create stunning patterns.

Screenshot: black line rotated with 3 degress intervals results in red pattern: enter image description here

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.