Hi,<br>JFYI i have implemented a small demo library which connects parts of the grass gis library <br>with the Visual-Tool-Kit VTK. <br>It is called vtkGRASSBridge.<br><br>Additionally the VTK Python and Java wrapping mechanism have been enabled. So the user can use the <br>
library from C++, Python and Java.<br><br>Features:<br>* The library can read and write raster maps row by row, as well as regions and the raster history.<br>* It can list files of the grass database.<br>* It can convert grass raster maps into the vtkImageData format and the other way round.<br>
Missing Features:<br>* Full raster support (categories, colors, ..)<br>* Imagery support (groups, ...)<br>* Full vector support ....<br>* ....<br><br>You can use every vtkDataSet processing algorithm available in VTK (more than 50 i think)<br>
to process the converted raster map and write it back to the grass raster database.<br><br>You can use the VTK render functionality to display the raster map.<br><br>There are examples and tests in the library showing this functionality in Python.<br>
<br>The documentation of the library can be found here:<br><a href="http://www-pool.math.tu-berlin.de/~soeren/grass/files/vtkGRASSBridge/doc/html/index.html">http://www-pool.math.tu-berlin.de/~soeren/grass/files/vtkGRASSBridge/doc/html/index.html</a><br>
<br>The GPL source code is located here:<br> <a href="http://www-pool.math.tu-berlin.de/~soeren/grass/files/vtkGRASSBridge/vtkGRASSBridge_0.1.tar.gz">http://www-pool.math.tu-berlin.de/~soeren/grass/files/vtkGRASSBridge/vtkGRASSBridge_0.1.tar.gz</a><br>
<br>Here is a small Python code example to read and write grass raster maps in Python (within a grass session):<br><br>##############################################<br>#include the VTK and vtkGRASSBridge Python libraries<br>
from libvtkCommonPython import *<br>from libvtkFilteringPython import *<br>from libvtkGraphicsPython import *<br>from libvtkRenderingPython import *<br>from libvtkIOPython import *<br>from libvtkImagingPython import *<br>
from libvtkGRASSBridgeIOPython import *<br>from libvtkGRASSBridgeCommonPython import *<br><br>#Initiate grass<br>init = vtkGRASSInit()<br><br>#The region settings<br>region = vtkGRASSRegion()<br>region.ReadCurrentRegion()<br>
region.SetCols(10)<br>region.SetRows(10)<br>region.AdjustRegion()<br><br>#Create a new map and write some data into it<br>writer = vtkGRASSRasterMapWriter()<br>writer.SetMapTypeToCELL()<br>writer.SetRegion(region)<br>writer.UseUserDefinedRegion()<br>
writer.OpenMap(&quot;test_cell&quot;)<br><br>#this is the row buffer<br>data = vtkIntArray()<br>data.SetNumberOfTuples(writer.GetNumberOfCols())<br><br>#iterate over each raster cell<br>for i in range(writer.GetNumberOfRows()):<br>
    for j in range(writer.GetNumberOfCols()):<br>        data.SetTuple1(j, i + j + 100)<br>    writer.PutNextRow(data)<br><br>#close the map<br>writer.CloseMap()<br><br>#now reopen the map for reading<br>reader = vtkGRASSRasterMapReader()<br>
reader.OpenMap(&quot;test_cell&quot;)<br><br>#print the cells to stdout<br>print &quot; &quot;<br>for i in range(reader.GetNumberOfRows()):<br>    data = reader.GetRow(i)<br>    for j in range(reader.GetNumberOfCols()):<br>
        print data.GetTuple1(j),<br>    print &quot; &quot;<br><br>#print the range of the raster map<br>val = [0,0]<br>reader.GetRange(val);<br>print &quot;Range &quot;, val<br><br>#print the history<br>print reader.GetHistory()<br>
reader.CloseMap()<br><br>#############################################<br><br><br>Have fun<br>Soeren<br>