[GRASS-dev] GsoC2012: High level map interaction with python

Sören Gebbert soerengebbert at googlemail.com
Wed Apr 4 08:14:06 EDT 2012

Hi Pietro,
more below:

2012/4/4 Pietro <peter.zamb at gmail.com>:
> Hi Sören,
> 2012/4/4 Sören Gebbert <soerengebbert at googlemail.com>:
>> Hi Pietro,
>> this is an interesting and very useful submission. A numpy matrix
>> interface would be a valuable addition, but as Markus Metz said, we
>> need also direct row access without reading the whole raster or vector
>> map into the memory.
> Exactly, I'm not interesting to the numpy interface, I'm interested to
> use the grass data library in a more pythonic way, similar to numpy
> but using all the smart things that GRASS have.
>> Actually with the vtk-grass-bridge there is already an object
>> orientated interface to the grass raster, vector and voxel libraries
>> providing convenient high level access classes and methods for C++,
>> Java and Python[1]. You may orient on this interface when designing
>> the Python GRASS classes?
>> [1] http://code.google.com/p/vtk-grass-bridge
> Thank you for the link, I didn't know this interface. It seem quite
> far from a python style: the PEP 8 style guide (Python) says
> methodnames should be lowercase and that sometimes method_names may
> have embedded underscores ...

The VTK GRASS bridge uses the VTK style[1]. This assures the same
convincing coding style in
C++, Java and Python. Therefore it is not Python specific but it
integrates itself into the VTK
pipeline framework to use the more than 500 existing algorithms of VTK
for image, voxel and vector processing.

For example the Delaunay triangulation is now as simple as it can be:
# Init grass variables
init = vtkGRASSInit()

# Build the VTK pipeline
# This reader does not need topology information
reader = vtkGRASSVectorPolyDataReader()

# The Delaunay triangulation
delaunay = vtkDelaunay2D()

# Start the processing (udpate) and write the resulting
# grass vector map into the grass database
writer = vtkGRASSVectorPolyDataWriter()

The idea why i am pointing you to this interface is not use use its
coding style, but to get an idea what
classes are needed and how they should be designed to access the low
level GRASS library functions.
You will have to think about this aspect too, since these access
methods are needed to implement
more complex and massive data processing ready algorithms. So maybe
the vtk-grass-bridge will give you
some interesting insights how the C-level of GRASS works?

Best regards

[1] http://www.vtk.org/Wiki/VTK_Coding_Standards

I included developer list in CC to get this discussion back to the list

More information about the grass-dev mailing list