Coder Social home page Coder Social logo

joeberkovitz / qgis-compass-routes Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.04 MB

This QGIS plugin creates vector layers that work with magnetic variation.

License: GNU General Public License v2.0

Makefile 9.48% Python 57.36% Ruby 1.28% QML 31.89%
qgis magnetic north bearing compass declination variation maps

qgis-compass-routes's Introduction

permalink
index.html

qgis-compass-routes

This plugin creates vector layers that use magnetic variation. It also adds a couple of custom expression functions that provide access to the underlying geomagnetic model used by the plugin.

All actions are available as menu commands (available under Plugins > Compass Routes) and as Processing scripts.

Processing scripts

Route segments Create Compass Route Layer

This menu command adds a new Line layer with memory storage, whose lines render as arrows that are automatically labeled with distance and magnetic heading.

The new layer, named Routes, is initially empty. Lines in the layer are automatically labeled in this fashion:

Route segments

The magnetic variation for each label is dynamically computed from a geomagnetic model, using the current date. Altitude is ignored; magnetic variation is computed at sea level.

Note that you must create only one line per feature. Multi-lines with multiple segments are not labeled nicely, and the label reflects the total length and bearing of the multi-line, rather than of each segment.

An explicit label attribute is created for each feature, normally left blank. If set, this custom text will replace the automatically computed label:

Route segments

Hovering over a line always shows its length and magnetic/true bearings regardless of any custom label.

The following virtual fields are available for each feature in the layer:

  • bearing_true and bearing_magnetic are the feature bearings in degrees for true and magnetic respectively.
  • label_true and label_magnetic are the default labels incorporating distance and bearing, for true and magnetic respectively.

Create Magnetic North Lines

This processing script adds a vector layer containing magnetic north lines within a given extent. Lines are spaced by a given distance and are broken and redrawn to preserve this spacing within an error tolerance.

Altitude is ignored; the variation is computed at sea level.

Parameters to the script are as follows:

Extent is the rectangle within which lines will be added. It's typically convenient to use the dropdown to default this to the map canvas view area, or to draw a rectangle on the map canvas.

Units of measure provides the units in which the various other distance-related parameters are expressed. It defaults to nautical miles.

Distance between adjacent lines gives the parallel distance between adjacent magnetic north lines. This distance is only approximate as field lines will converge as traced towards the magnetic poles: the plugin preserves the accuracy of variation at the expense of line spacing.

Tracing resolution of field lines governs the resolution of field lines. Each line is created by repeatedly advancing at roughly this interval along the field, yielding a number of points. These are then connected to form an approximation to the field line.

Maximum distance error between lines specifies the largest error in line spacing that will be tolerated before a traced line is ended and a new one begun at the proper distance from the previous one. (Note that lines are traced from south to north, so the initial spacing is correct on the south side of the extent.) Provide zero for this parameter to force lines to be generated continuously with no breaks, but with unpredictable spacing on the north of the extent. This is useful for visualizing the field over large areas.

Maximum variation error within lines specifies the largest error in magnetic variation that will be tolerated before a traced line is ended and a new one begun at the current point. This does not create a visual break, but does result in a new line object whose variation tool tip (or label, if desired) will remain accurate to within the given tolerance. Provide a zero value to disregard variation changes within a line.

Output layer is a vector layer in which the results will be placed. The CRS of the layer is always EPSG:4326 regardless of the project CRS.

An example of a generated grid at a small scale looks like this (accepting the defaults for a 1 nm spacing):

Magnetic north lines

At a larger scale, the breaking of lines to preserve distance spacing looks like this (each line is labeled with its variation for clarity):

Broken magnetic north lines

Expression Functions

These functions may be used for dynamic computation of magnetic variation in QGIS expressions.

magnetic_north(lat, long [,altitude [,date]])

Obtains the magnetic variation at some given coordinates.

  • lat -- latitude as a number in signed degrees
  • long -- longitude as a number in signed degrees
  • altitude -- optional altitude in meters; defaults to zero
  • date -- a date or time at which the variation should be computed

to_magnetic(bearing, lat, long [,altitude])

Converts a true bearing at some given coordinates to a magnetic bearing in the range 0-360, for the current date.

  • bearing -- a true bearing in degrees
  • lat -- latitude as a number in signed degrees
  • long -- longitude as a number in signed degrees
  • altitude -- optional altitude in meters; defaults to zero

Credits

For dynamic computation of magnetic declination, uses the geomag package by Christopher Weiss - see https://github.com/cmweiss/geomag

Adapted from the geomagc software and World Magnetic Model of the NOAA Satellite and Information Service, National Geophysical Data Center.

Model values by NCEI Geomagnetic Modeling Team and British Geological Survey. 2019. World Magnetic Model 2020. NOAA National Centers for Environmental Information. doi: 10.25921/11v3-da71, 2020.

qgis-compass-routes's People

Contributors

joeberkovitz avatar

Watchers

 avatar

qgis-compass-routes's Issues

Relabel lines when variation changes sufficiently

Magnetic north lines are continued as polylines without relabeling even though the variation could drift significantly as the line is traced. Ideally a new polyline could be restarted "in place" with no visual break, which would result in a new variation label for the restarted line.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.