Contour plugin help

Button image

This plugin is designed for contouring points datas to a line or a polygon vector layer. Thanks to the matplotlib library, it's now trivial to contours any point layer with datas gridded or not with the Delaunay triangulation algorithm.

So, this plugin requires

  • numpy
  • matplotlib version 1.0 or above
  • to be installed.

    The plugin installs a menu item (Plugins|Contour|Contour) and a button in the plugins toolbar. To contour data in a point layer, select the menu item or click the button.

    The contour dialog

    Contour dialog

    The contour dialog is used to contour point data. To generate contours, select the required options, then press OK. More than one set of contours can be generated. When all the required contours have been generated, press Close to quit the dialog. If a contour layer is selected when the dialog is opened then the original settings will be reloaded and the layer can be updated.

    The plugin can use two different methods for contouring. For gridded data the plugin can take advantage of the gridded layout to calculate contours more efficiently. Gridded data does not need to be spaced regularly, but the plugin does require that the data are ordered by rows and columns (or vice versa). For data not gridded in this way the plugin will build a Delauney triangulation and then contour based on that.

    The input box is used to select the data to be contoured. This requires choosing the map layer containing the data (only point layers are available), and the data field of the layer containing the values to be contoured.

    Contours can be displayed either as line features along the contour levels, or as polygon features (defining the area between each set of contour lines), or both.

    The number of levels, minimum and maximum values and the computation method can be used to calculate the contour levels.

    Possible computation methods are Equal (contours at equal intervals), Quantile (contours at equal quantiles of the data set), or Manual. The manual option limits automatic recalculation - for example values are not recalculated if a different data field or vector layer is selected.

    When the data are read, the minimum and maximum values of the data field are calculated and displayed. They can then be edited to choose different minimum and maximum contour levels. The number of levels includes the minimum and maximum values. So for example choosing minimum 200.0, maximum 600.0, and 5 levels equally spaced will generate contours at 200, 300, 400, 500, and 600. An extend option can be selected to generate closed filled contours (in our example, if a levels of 600 to infinity is required, then select extend=max will compute this level).

    Contour levels dialog

    When the minimum and maximum values and the number of levels have been set the calculated contour levels will be displayed in a list. These can be edited individually or completely replaced by double clicking on them. This will open the "Update level" dialog box. The clicked level will be displayed. Use Shift+double click on the list to load all the levels at once. To replace the clicked level just enter the new value and press Ok. To replace the entire list enter all the required contour levels separated by space characters.

    You can also edit the resulting layer name and the labelling precision in the "Output" box. The "label precision" is a convenient way to format the "label" attribute of the resulting layer, which then can be directly used and displayed in the "Categorized" renderer. It also is used as the precision of automatically calculated labels. The Label units text is a string that is appended to the values to create the level label.

    The resulting layer can be rendered using colours from a selected color ramp.

    The plugin provides an option of thinning the points before contouring. This may be necessary if the input data include points very close together, as in this case the matplotlib contouring function can fail to work. The plugin uses a crude point thinning algorithm to choose a subset of points to use for the contouring. The point thinning radius is in the units of the coordinate system, typically either degrees or metres.

    By default the plugin will use will use a grid based contouring algorithm if it detects that the data is in a regular grid. This will only apply if the order that the data are read follows either a column or row major order through the grid. Unchecking the "Use grid based contouring" check box will force the plugin to use a triangulation based contouring algorithm.

    Warning messages

    The contour plugin may generate a number of warnings. Most are self expalanatory, requesting information that is not supplied or is not correct. Some less obvious messages are:

    Levels not represented: ...

    No contours will be drawn for the requested contour values because they are beyond the range of the data. Another case is that the values are on unsatisfying number of points, because a contour (line) needs at least 2 points and a filled contour (polygon) 3 points. A workaround is to select a lesser maximum value and/or a bigger minimum value.

    Exception encountered ...

    This is usually due to data containing duplicate points or points near to each other. This may be fixed by using the point thinning option (or trying different thinning radius values).

    Matplotlib contouring routine has generated # invalid geometries

    The contouring library used by the plugin sometimes generates self-intersecting polygons that are not valid OGC geometries. Usually this is due to a series of points in a straight line on the outside boundary of the set of data points (for example in gridded data sets). This is especially true if the triangulated contour method is being used. The plugin will attempt to repair geometries by buffering, but if this fails it will add the invalid geometry to the contour layer. This can result in rendering errors (for example the polygons not being rendered in some views).

    Thanks for trying this plugin

    Authors : Lionel Roubeyrie, Chris Crook