当前位置: 首页>>代码示例>>Python>>正文


Python rasterio.windows方法代码示例

本文整理汇总了Python中rasterio.windows方法的典型用法代码示例。如果您正苦于以下问题:Python rasterio.windows方法的具体用法?Python rasterio.windows怎么用?Python rasterio.windows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rasterio的用法示例。


在下文中一共展示了rasterio.windows方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: block_shape

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def block_shape(self, value):
        """Set the windows size used for raster calculations, specified as a tuple
        (rows, columns).

        Parameters
        ----------
        value : tuple
            Tuple of integers for default block shape to read and write data from the
            Raster object for memory-safe calculations. Specified as (n_rows,n_columns).
        """
        if not isinstance(value, tuple):
            raise ValueError(
                "block_shape must be set using an integer tuple " "as (rows, cols)"
            )

        rows, cols = value

        if not isinstance(rows, int) or not isinstance(cols, int):
            raise ValueError(
                "tuple must consist of integer values referring "
                "to number of rows, cols"
            )

        self._block_shape = (rows, cols) 
开发者ID:stevenpawley,项目名称:Pyspatialml,代码行数:26,代码来源:raster.py

示例2: block_shapes

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def block_shapes(self, rows, cols):
        """Generator for windows for optimal reading and writing based on the raster
        format Windows are returns as a tuple with xoff, yoff, width, height.

        Parameters
        ----------
        rows : int
            Height of window in rows.

        cols : int
            Width of window in columns.
        """

        for i in range(0, self.width, rows):
            if i + rows < self.width:
                num_cols = rows
            else:
                num_cols = self.width - i

            for j in range(0, self.height, cols):
                if j + cols < self.height:
                    num_rows = rows
                else:
                    num_rows = self.height - j

                yield Window(i, j, num_cols, num_rows) 
开发者ID:stevenpawley,项目名称:Pyspatialml,代码行数:28,代码来源:raster.py

示例3: divide_chunks

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def divide_chunks(l,n):
    # looping till length l 
    for i in range(0, len(l), n):  
        yield l[i:i + n] 
#建立用于rasterio库分批读取一个较大Raster数据的windows列表(如果内存溢出,而要处理较大的单独raster数据时)
#关于rasterio的window数据格式可以查看其官方网站 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:8,代码来源:distanceWeightCalculation_raster2Polygon.py

示例4: rasterio_windows

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def rasterio_windows(totalWidth,totalHeight,subWidth,subHeight):
    w_n=list(divide_chunks(list(range(totalWidth)), subWidth))
    h_n=list(divide_chunks(list(range(totalHeight)), subHeight))
    wins=[Window(w[0],h[0],len(w),len(h)) for h in h_n for w in w_n]
    # print(wins)
    print("raster windows amount:",len(wins))
    return wins

#meter=degree*(2 * math.pi * 6378137.0)/ 360  degree=50/(2 * math.pi * 6378137.0) * 360 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:11,代码来源:distanceWeightCalculation_raster2Polygon.py

示例5: divide_chunks

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def divide_chunks(l,n):
    # looping till length l 
    for i in range(0, len(l), n):  
        yield l[i:i + n] 

#建立用于rasterio库分批读取一个较大Raster数据的windows列表(如果内存溢出,而要处理较大的单独raster数据时)
#关于rasterio的window数据格式可以查看其官方网站 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:9,代码来源:rasterBuildingHeightZSplit.py

示例6: rasterio_windows

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def rasterio_windows(totalWidth,totalHeight,subWidth,subHeight):
    w_n=list(divide_chunks(list(range(totalWidth)), subWidth))
    h_n=list(divide_chunks(list(range(totalHeight)), subHeight))
    wins=[Window(w[0],h[0],len(w),len(h)) for h in h_n for w in w_n]
    # print(wins)
    '''之下的代码繁复,并无法处理边界高宽问题,弃之'''
    # if totalWidth%subWidth==0 and totalHeight%subHeight==0:
    #     w_n=[subWidth*i for i in range(totalWidth//subWidth)]
    #     h_n=[subHeight*i for i in range(totalHeight//subHeight)]
    #     wins=[Window(w,h,subWidth,subHeight) for h in h_n for w in w_n]
    
    # if totalWidth%subWidth==0 and totalHeight%subHeight!=0:
    #     w_n=[subWidth*i for i in range(totalWidth//subWidth)]
    #     h_n=[subHeight*i for i in range(totalHeight//subHeight+1)]
    #     wins=[Window(w,h,subWidth,subHeight) for h in h_n for w in w_n]
            
    # if totalWidth%subWidth!=0 and totalHeight%subHeight==0:
    #     w_n=[subWidth*i for i in range(totalWidth//subWidth+1)]
    #     h_n=[subHeight*i for i in range(totalHeight//subHeight)]
    #     wins=[Window(w,h,subWidth,subHeight) for h in h_n for w in w_n]    
        
    # if totalWidth%subWidth!=0 and totalHeight%subHeight!=0:
    #     w_n=[subWidth*i for i in range(totalWidth//subWidth+1)]
    #     h_n=[subHeight*i for i in range(totalHeight//subHeight+1)]
    #     wins=[Window(w,h,subWidth,subHeight) for h in h_n for w in w_n]            
        
    print("raster windows amount:",len(wins))
    return wins

#testing 测试部分,可丢弃 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:32,代码来源:rasterBuildingHeightZSplit.py

示例7: rasterio_windows

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def rasterio_windows(totalWidth,totalHeight,subWidth,subHeight):
    w_n=list(divide_chunks(list(range(totalWidth)), subWidth))
    h_n=list(divide_chunks(list(range(totalHeight)), subHeight))
    wins=[Window(w[0],h[0],len(w),len(h)) for h in h_n for w in w_n]
    # print(wins)
        
    print("raster windows amount:",len(wins))
    return wins

# @njit(parallel=True)
#栅格重分类计算。如果栅格数据很大,采用rasterio的window读取数据,并计算,可以避免内存溢出 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:13,代码来源:rasterBuildingHeightZSplit_reclassify.py

示例8: rasterio_windows

# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import windows [as 别名]
def rasterio_windows(totalWidth,totalHeight,subWidth,subHeight):
    w_n=list(divide_chunks(list(range(totalWidth)), subWidth))
    h_n=list(divide_chunks(list(range(totalHeight)), subHeight))
    wins=[Window(w[0],h[0],len(w),len(h)) for h in h_n for w in w_n]
    # print(wins)
    print("raster windows amount:",len(wins))
    return wins


# @njit(parallel=True)
# @cuda.jit(debug=True) 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:13,代码来源:SVF_array_Final_bigRaster.py


注:本文中的rasterio.windows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。