GRASS 7 ideas collection

From GRASS-Wiki
Jump to: navigation, search
 New home:
 See also:

Maintenance of repository

For GRASS 7 development is used svn-trunk, for GRASS 6 development is used separated SVN branch develbranch_6.

  Planning is continued here:


See GRASS 7 Terminology.

List of new features in GRASS 7 (already implemented)


API to access algorithms in modules

We need to better expose the "knowledge" which is contained at module level. We want to have it accessible via API, exposed in various programming languages such as C, Python, Perl, Java, ..

Update 1/2011: Python ctypes interface available, also PyGRASS, see

See how the temporal modules and temporal library is done.

Dead code cleanup

? unclear: Trash or move to addons?

  • general/g.setproj - partially replaced by `g.proj -c` but contains still useful logic
  • vector/ see trac #1942 and r34923. It probably shouldn't be dealing with FreeType directly. Glynn suggests using the display API, specifically D_get_text_box() rather than trying to calculate a skyline.


  • imagery/ - should remain: trac #2461
  • imagery/ - should remain: trac #2461
  • raster/r.watershed/shed - keep for a future reference (e.g., for development of a wizard in a GSoC)



The raster data API has been updated. See also

Raster Library

Raster map "history" metadata:

  • In 7.0, the fields of the history structure are dynamically allocated. You have to use Rast_set_history() or Rast_format_history() to set fields. The the HIST_* constants have to be used.

About cell_misc/null file size:

The size of the cell_misc/<mapname>/null file depends only upon the number of rows and columns, not the data. It's one bit (null/non-null) for each cell, rounded to an integral number of bytes per row (i.e. the number of columns is rounded up to the nearest multiple of 8).

Segment Library

(from trac #2296): we should look into unifying all of the different "segment" libraries.

They all do essentially the same thing: provide a 2-dimensional array which may be too large to fit into RAM (or, more accurately, into the process' address space; if RAM was the issue, mmap() etc would suffice), and which can be accessed (more or less) randomly.

Apart from the "official" segment library (lib/segment), r.proj has its own,* each have their own, r.grow.distance has something simpler (the temporary file is read row-by-row but in reverse).



  • rename to r.import - see discussion - new r.import
  • rename r.out.gdal to r.export - see discussion
  • rename r.volume 'data' parameter to something more standard like 'input' - done.

* r.stats vs r.statistics vs r.statistics2 vs r.statistics3:

    • r.statistics2 has been renamed to r.stats.zonal
    • r.statistics3 has been renamed to r.stats.quantile


see delta comment about r.out.tiff below, sometimes the simple stuff works best! --HB
  • remove r.resample and r.bilinear in favor of r.resamp.interp
TODO: double-check that r.resample is in fact fully replaced by 'r.resamp.interp's method=nearest'. ie check that an alternate useful method is not lost.
  • remove; newly implemented r.univar features cover it - done.
  • remove r.out.tiff. New C r.out.gdal should cover all it's option now (doublecheck!). See RT #3680 (starting with date Sun, Nov 26 2006 14:54:23).
It might be worth keeping r.out.tiff! It makes a nice delta when things don't go well (eg QGIS bug#348) --HB
However: code duplication, maintenance overhead, user confusion (more entries in GUI, more manual pages, why are there modules doing the same?).
They do not do the same. r.out.gdal outputs data values, r.out.tiff outputs color values. Two completely different things. --HB
  • Remove remaining -v and -q flags for verbosity levels of modules.


while will only output CELL maps, it is Very Fast. (or that is to say, is Very Slow)
HB: eh? the options and algorithm are nothing alike.
MS: I meant that r.resamp.rst could be a subset of r.resamp.interp (yet another resampling algorithm next to nearest, bilinear, bicubic). I haven't considered that the number of rst options would make r.resamp.interp user interface much less clear. Maybe not such a good idea after all - user interface wise.
HB: just be careful that the GDAL version is as featureful and grid/cell center correct as the* versions. I suspect it might not be. needs further python rewrite with full XML and HTTP library support.
HB: why? they do two fundamentally different things, and both work quite nicely right now. One works in cell space, the other geographic space (especially for lat/lon).
MS: Right. The 2 modules do different things. But it would be usefull if r.grow supported distance in units and r.buffer in cells. Could both share same code for distance options?


  • fix the raster map history management (truncating long history, odd storage). It should work like for vector maps in GRASS 6.
  • r.volume centroids parameter only makes a level one vector with no attribute table; module should be updated to GRASS 6 vector library)
  • r.random should be split into 2 modules: one for generating a raster map with random points (alike v.random), and the other for sampling a raster map (alike v.what.rast). Vector functionality should be droped from r.random - a dupe of existing vector modules. -i and -z flags should be droped.
  • v.random -z: read zmin and zmax from region settings, drop zmin and zmax. I.e. treat Z coord same as X,Y.

Good coding practice

  • Input handling:
/* Define the different options */
input1               = G_define_standard_option(G_OPT_R_INPUT) ;
input1->key          = _("albedo");
input1->description  =_("Name of the Albedo map [0.0-1.0]");
input1->answer       =_("albedo");
input1->guisection   = _("Required");

In here you can find G_define_standard_option(G_OPT_R_INPUT) assuming already those:

  input1->type       = TYPE_STRING;
  input1->required   = YES;
  input1->gisprompt  =_("old,cell,raster") ;

If your input is not required to run the module, you just create the following line:

 input1->required   = NO;
  • In a similar way, metadata/history storage:
      G_short_history(result1, "raster", &history);
  • This is the standard incantation, but I have to find timestamp(), and

more details metadata maybe like sensor type for a start, or source/origin of data... Can we make metadata having elements (history->processing, history->timestamp, history->source(or history->origin), etc?) then it could be filled up specifically.

  • Or color palettes application is nice:
/* Color table for biomass */
  • Changes (from Glynn):

I would prefer it if G_open_*_new() simply called G_fatal_error() themselves if an error occurred. It's not as if there's any reasonable alternative way to handle the error.

  • Changes:
     input = G_define_option(G_OPT_F(D?)_INPUT) ;
     input->key        =_("parameter");
     input->type       = TYPE_DOUBLE;
     input->required   = YES;
     input->gisprompt  =_("value, parameter");
     input->description=_("Value of the parameter");
     /*input->answer     =_("0.000");*/
     input->guisection = _("Required");

I could also think similarly for non-GRASS files actually (configuration files sometimes need to be loaded separately)


Radim's TODO list

Vector TODO list

  • Particularly important: "Keep topology and spatial index in file instead of in memory" --ML
  • split long boundaries to speed up topology cleaning. Implemented in GRASS 7, partial backport to GRASS 6.5 possible. speed comparison


  • 2d 'vertical' vector data (e.g. Geologic Cross Sections)
  • implement transactions for geometry handling (esp. v.edit, v.digit and to avoid leftover files when a vector command fails)
  • Assume cat 0 as the first possible, instead of 1. GRASS has supported cat 0 since around 2005, but it hasn't been widely used. According to Radim, using cat 0 allows for exact mapping from OGR FID (which can be 0) to GRASS cat.
  • support for elliptical arcs, quadratic and cubic splines. Elliptical arcs or circular arcs are very common in Swiss survey data (Amtliche Vermessung)





  • merge and v.overlay
needs discussion, they are doing fundamentally different things --HB
See a feature request #506 in GForge.
see also v.rast.stats and v.what.rast.buffer addon


  • Fix the Column 'cat_' already exists (duplicate name) in Maybe by creating columns cat_1, cat_2 etc. each time a Grass vector is exported to shapefile and imported back to Grass?
  • write Vect_map_exists() and implement in g.remove and v.digit -n (why wait for GRASS 7 ??)
  • add '-d' dissolve to v.reclass
  • add 'where=' to (why wait for GRASS 7 ??)
  • implement Douglas-Peucker generalization (C code file)to substitute prune tool of v.clean (done?, see also GSoC)
  • Rewrite vector labeling. Needs more placement control options (may be db field value based), label overlapping prevention would be also good. May be we could borrow some ideas from MapServer? (ongoing:
  • v.what.vect - rename parameters "vector" to "map", "qvector" to "qmap"
  • v.type - change type= option to from= and to=.(code's already in there)


  • extend v.overlay to allow combination of all types (point, line, area)
  • v.category: add possibility to create new layer categories on the basis of a column in the table linked to an existing layer
  • v.generalize: add point cloud data reduction, e.g. with (ANN: A Library for

Approximate Nearest Neighbor Searching)

3D topology

Currently, GRASS' topological cleaning is 2D only. This will regularly corrupt 3D data that is actually topologically correct in 3D space, but appears incorrect in 2D space (e.g. 3D polygons that appear to overlap or have zero-area in the X-Y geographic reference plane). Therefore, v.clean in GRASS 7 should become more competent at handling 3D topology. This is a sketch of how to implement the same level of topology support that 2D geometries currently have in 3D space.

Problem structure

The classes of potential topological errors depend on the geometry type (point, line, polygon), in 3D just as in 2D. Each more complex geometry type inherits the potential problems of the less complex types, and adds its own.

  • 3D topological problems for points reduce to coincidence in 3D space.
  • 3D topological problems for lines are over- and undershoots as well as duplicate vertices. These are completely equivalent to the same problem in 2D space.
  • 3D topological problems for polygons appear much more complex, as they include areal overlap in 3D, and shared boundaries between adjacent polygons. But this complexity can be reduced significantly. Only polygons that lie in the same plane (including a small error margin -- could be implemented just like the minimum error option in v.clean) can get into topological trouble with each other: if two polygons do not lie in the same plane, then by definition they cannot overlap, only intersect. (It is open to debate, whether an intersection of polygons in 3D space would constitute a topological error.) Likewise, adjacent polygons can only have a shared boundary if they are neighbors on the same plane.

Basic approach

As a result, the topological cleaning could proceed as follows.

  1. All 3D polygons need to be planar, i.e. all of their vertices must lie on the same plane. If they are not, then this is a topological error, and the polygon needs to be planarized by v.clean (add a "planarize" action -- also potentially useful for other geometry types). Planarization is done by first calculating the plane equation of the polygon (a simple equation that defines the location and orientation of a best-fit 2D plane through all vertices) and then reprojecting each of its original vertices to the plane defined by the plane equation (it could make sense to store the plane equations as part of the topological data structure). Planarization needs to be carried out for both boundaries and islands.
  2. Once planarized, all polygons can be subjected to the exact same topological cleaning as 2D polygons:
    1. After planarization, group all polygons that lie on the same plane.
    2. For each "plane group": reproject all vertices to the geographic X-Y reference plane. Run the topological cleaning just like for 2D polygons, but preserve the Z coordinates.
    3. Then revert the projection of all vertices back to the group's original reference plane, using the plane equation.
    4. Do the same with the next "plane group" until all polygons have been processed.
  3. Faces (3D triangles) are primitives that are part of more complex 3D geometries (including TINs and 3D hulls). Topological problems involving such geometries are too complex to handle in GIS. Thus, faces should not be checked for overlap. GRASS GIS should just assume that faces are part of complex geometries that are not to be subjected to analytical treatment, but simple tasks, such as visualization, only. Therefore, only basic cleaning (check for duplicate coordinates, zero-area triangles, etc.) should be carried out. Faces are always planar by definition.
  4. The areas and centroids of both faces and planar polygons can be calculated in 3D space just as they can be calculated in 2D space.

Implementation details

A simple algorithm for computing the plane equation of a set of vertices is <missing URL> available in the form of Newell's Method. This method requires three points to define a plane. This requirement is met by even the most simply polygons. However <missing URL>: "Newell's method is known to fail if the 3 points are chosen around a concave corner - the normal of the resulting plane will point in the direction opposite to the expected one." (This should be avoidable by taking three vertices at the extreme edges.)

Since the planar equation is a best-fit model, not always an exact solution, a warning should be issued if an error threshold is reached.

3D point clouds



  • Add support for planetary bodies reference systems
  • Add new partial differential equation (PDE) library with OpenMP support (GRASS 6.3)


  • g.remove, g.mremove, g.rename, g.copy: don't allow for default datatype (which is currently raster) [1].
controversial, needs more discussion --HB
  • g.region
    • Glynn's notes - cleaning the print flags and new print= option
    • Support vector's 3rd dimension in g.region vect= [-a], [res=], like the 2d extents are (or should be) see trac #121



  • establish SQLite as default DBMI driver for vector attribute storage (DBF is too limited). done May 2008.


  • allow cross-mapset database access, i.e. parse the '@mapset' notation appended to vector names (requires access via possibly different DBMI drivers)


  • rename to db.import


Page has been moved to Trac:



  • renaming of all G3D library functions to fulfil the grass coding standard
  • extent/rewrite documentation
  • localisation support (why wait for GRASS 7 ??)



  • report and support modules like r3.stats,
  • voxel -> vector (isosurfaces ...) and vector -> voxel (lines, faces, volumes) conversion modules
  • module for 3d Kriging interpolation based on vector points
  • a GRASS-Python/VTK visualisation/manipulation tool


The page moved to Trac:



  • remove scale parameter
-> from the command line, not the map instruction

See also "New display architecture" comments above.


  • Making GRASS modules be less verbose. Use --verbose flag and GRASS_VERBOSE environment variable. All output (G_message, G_percetn, G_warning) should go to GRASS_LOG file which could be grassdata/location/mapset/.grass.log by default.
less verbose: this is well underway in 6.3
Note warning and errors are already logged to GIS_ERROR_LOG (see variables.html)

Init shell and startup

  • .grassrc6 is not what you expect. It holds the g.gisenv GIS variables, it's not a shell script containing commands like .bashrc is.
Suggestion: We should change the name for 7.x. It isn't an "rc" file in the conventional sense.
Suggestion: make it even a $HOME/.grass7/ directory to store settings etc (e.g., from and others)
  • It is asked to run GRASS in its own shell to avoid portability issues 1.
  • Eliminate Glynn explains on GRASS user ML: "Most of the environment can be set up through an e.g. /etc/env.d/grass script. The database, location and mapset can be set through g.mapset. The only slight subtlety is if you want multiple independent sessions, but that can be done with a fraction of the code in"
  • Provide a mechanism (g.access option?) to enable r/w access for users in mapsets they don't own. So that it they don't need to hack lib/gis/mapset_msc.c. Glynn explains on GRASS user ML: "AFAICT, that restriction has been unnecessary ever since the lockfile was moved from the user's home directory to the mapset directory."
Actually, I (Glynn) no longer think it's that simple. If other users can create directories within your mapset, they can create directories which you cannot remove, and in which you cannot add, remove or modify files. And this is quite likely to happen: most users will have a umask of 0022 or worse, meaning that other users (i.e. you) cannot modify any files or directories which they create.

Data management

  • store vertical units on per-map base, using code from units software
Support for free form unit meta-data added in 6.3. I don't mind it as a guide, but we shouldn't be limited to units found in units. --HB
  • store vertical map datum on per-location base (GDAL/OGR needs the same enhancement)
This requires more discussion. I'm not sure it's a good idea to do this location-wide. --HB
On a per raster map basis done in 6.3 cvs.
  • add versioning for maps (to recover previous map versions)
see " -h" ?

Time series

for example? r.rast4d


  • better support for faces and kernels in libgis
not really Visualization, but....


Parameters standardization

Flags standardization

  • Get rid of 'quiet/verbose' flags, preparation in GRASS 6, e.g.:
    /* please, remove before GRASS 7 released */
    if(q->answer) {
        G_warning(_("The '-q' flag is superseded and will be removed "
            "in future. Please use '--quiet' instead"));


  • Multiplatform
  • Fast, minimalist, number of windows reduced
  • Novice, ...., Expert profiles for the GUI (with reduced features), tailored for use cases, e.g. 3D models of a risk map,
  • link from application to the relevant wiki online support, so that non-programmers can contribute to GRASS support
  • compile wiki online content and help pages into a offline version of help pages for usage in GRASS without internet access.
  • Manageable also from command line via d.* modules
  • Facilitating easy development of custom GUI application based on GRASS
  • drop d.m
  • drop gis.m

Conceptual changes

  • File organization in binaries:
    • the grass etc dir is a mess... module should maintain arch-deps and arch-indep things in different paths -- frankie at #grass irc
    • it's basically a FHS violation, i dunno if it is reported by lintian, anyway /usr/lib/grass should be used for arch-deps data, not for mixed stuff -- frankie at #grass irc
  • Creating $HOME/.grass7 directory for
    • Custom fonts
    • and other modules temp. files
    • GEM addons installation
    • Default path for custom scripts
    • Custom symbols and EPS fill patterns
    • Custom color maps
    • Add here new item...

User Wishes

This section is not really development related...

  • Create 3D animation w nviz showing GRASS 3D coolness. MarisN 12:00, 4 August 2006 (CEST)
  • here are some examples to get inspired (apparently that's already possible):
  • Convince the users to use ParaView [2] for sophisticated animations --huhabla 20:47, 14 August 2006 (CEST)
    • (Add support for Paraview in GDAL/OGR or add GDAL/OGR support in ParaView to read directly data from GRASS) see discussion
  • Or use VisIt software, it should be able to read GRASS maps directly via GDAL

Complete GRASS Test Suite: see activity on Test Suite development page

  • base a comprehensive test suite on Soeren's GRASS Test Suite
  • automated error checking on all modules to catch data corruption issues