histogram_test.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:geopyspark 作者: locationtech-labs 项目源码 文件源码
def test_bin_counts(self):
        metadata2 = {'cellType': 'int32ud-500',
                     'extent': self.extent,
                     'crs': '+proj=longlat +datum=WGS84 +no_defs ',
                     'bounds': {
                         'minKey': {'col': 0, 'row': 0},
                         'maxKey': {'col': 0, 'row': 0}},
                     'layoutDefinition': {
                         'extent': self.extent,
                         'tileLayout': {'tileCols': 4, 'tileRows': 4, 'layoutCols': 1, 'layoutRows': 1}}}

        arr2 = np.int8([[[1, 1, 1, 1],
                         [3, 1, 1, 1],
                         [4, 3, 1, 1],
                         [5, 4, 3, 1]]])

        tile2 = Tile(arr2, 'INT', -500)
        rdd2 = BaseTestClass.pysc.parallelize([(self.spatial_key, tile2)])
        tiled2 = TiledRasterLayer.from_numpy_rdd(LayerType.SPATIAL, rdd2,
                                                 metadata2)

        hist2 = tiled2.get_class_histogram()
        bin_counts = hist2.bin_counts()

        self.assertEqual(bin_counts, [(1, 10), (3, 3), (4, 2), (5, 1)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号