[GRASS-SVN] r55712 - grass/trunk/lib/python/temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 12 01:21:43 PDT 2013


Author: huhabla
Date: 2013-04-12 01:21:42 -0700 (Fri, 12 Apr 2013)
New Revision: 55712

Modified:
   grass/trunk/lib/python/temporal/__init__.py
   grass/trunk/lib/python/temporal/space_time_datasets.py
Log:
Enabled 3D raster numpy access in the temporal GIS library.
Added missing module to __init__.py


Modified: grass/trunk/lib/python/temporal/__init__.py
===================================================================
--- grass/trunk/lib/python/temporal/__init__.py	2013-04-12 00:05:17 UTC (rev 55711)
+++ grass/trunk/lib/python/temporal/__init__.py	2013-04-12 08:21:42 UTC (rev 55712)
@@ -4,6 +4,7 @@
 from spatial_extent import *
 from metadata import *
 from abstract_dataset import *
+from abstract_temporal_dataset import *
 from abstract_map_dataset import *
 from abstract_space_time_dataset import *
 from space_time_datasets import *

Modified: grass/trunk/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets.py	2013-04-12 00:05:17 UTC (rev 55711)
+++ grass/trunk/lib/python/temporal/space_time_datasets.py	2013-04-12 08:21:42 UTC (rev 55712)
@@ -397,6 +397,28 @@
         else:
             return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
+    def get_np_array(self):
+        """!Return this 3D raster map as memmap numpy style array to access the 3D raster
+           values in numpy style without loading the whole map in the RAM.
+
+           In case this 3D raster map does exists in the grass spatial database, 
+           the map will be exported using r3.out.bin to a temporary location 
+           and assigned to the memmap object that is returned by this function.
+
+           In case the 3D raster map does not exists, an empty temporary 
+           binary file will be created and assigned to the memap object.
+
+           You need to call the write function to write the memmap 
+           array back into grass.
+        """
+
+        a = garray.array3d()
+
+        if self.map_exists():
+            a.read(self.get_map_id())
+
+        return a
+        
     def reset(self, ident):
         """!Reset the internal structure and set the identifier"""
         self.base = Raster3DBase(ident=ident)



More information about the grass-commit mailing list