소스 검색

Enabled 3D raster numpy access in the temporal GIS library.
Added missing module to __init__.py


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55712 15284696-431f-4ddb-bdfa-cd5b030d7da7

Soeren Gebbert 12 년 전
부모
커밋
67eb919657
2개의 변경된 파일23개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      lib/python/temporal/__init__.py
  2. 22 0
      lib/python/temporal/space_time_datasets.py

+ 1 - 0
lib/python/temporal/__init__.py

@@ -4,6 +4,7 @@ from temporal_extent import *
 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 *

+ 22 - 0
lib/python/temporal/space_time_datasets.py

@@ -397,6 +397,28 @@ class Raster3DDataset(AbstractMapDataset):
         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)