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


Python mapnik.Box2d方法代码示例

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


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

示例1: write_metadata

# 需要导入模块: import mapnik [as 别名]
# 或者: from mapnik import Box2d [as 别名]
def write_metadata(bbox, mwidth, mheight, transform, img_output_file, wld_file=None, ozi_file=None):
    """Write worldfile and/or OZI file if required.

    Parameters
    ----------
    bbox: mapnik.Box2d
        bounding box of the map
    mwidth : int
        width of the image
    mheight : int
        height of the image
    transform : mapnik.ProjTransform
        transformation from EPSG:4326 to the target projection
    img_output_file : str
        image output path (required for OZI file)
    wld : file
        file pointer to the world file to be written (or None if non has to be written)
    ozi : file
        file pointer to the OZI file to be written (or None if non has to be written)
    """
    if ozi_file:
        ozi_file.write(prepare_ozi(bbox, mwidth, mheight, img_output_file, transform))
    if wld_file:
        wld_file.write(prepare_wld(bbox, mwidth, mheight)) 
开发者ID:Zverik,项目名称:Nik4,代码行数:26,代码来源:nik4.py

示例2: render_to_file

# 需要导入模块: import mapnik [as 别名]
# 或者: from mapnik import Box2d [as 别名]
def render_to_file(self, xmin, ymin, xmax, ymax, path):
        extent = mapnik.Box2d(xmin, ymin, xmax, ymax)
        self._map.zoom_to_box(extent)
        mapnik.render_to_file(self._map, path) 
开发者ID:perliedman,项目名称:shadow-mapper,代码行数:6,代码来源:render_background.py

示例3: renderArea

# 需要导入模块: import mapnik [as 别名]
# 或者: from mapnik import Box2d [as 别名]
def renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom):
        '''
        '''

        # NB: To be thread-safe Map object cannot be stored in the class state.
        # see: https://groups.google.com/forum/#!topic/mapnik/USDlVfSk328

        Map = mapnik.Map(width, height, srs)
        Map.zoom_to_box(Box2d(xmin, ymin, xmax, ymax))

        Map = self.style_map(Map)

        img = mapnik.Image(width, height)
        # Don't even call render with scale factor if it's not
        # defined. Plays safe with older versions.
        if self.scale_factor is None:
            mapnik.render(Map, img)
        else:
            mapnik.render(Map, img, self.scale_factor)

        def gamma_correct(im):
            """Fast gamma correction with PIL's image.point() method."""
            if self.gamma != 1.0:
                table = [pow(x / 255., 1.0 / self.gamma) * 255
                         for x in range(256)]
                # Expand table to number of bands
                table = table * len(im.mode)
                return im.point(table)
            else:
                return im

        # b = BytesIO(img.tostring())
        img = Image.frombytes('RGBA', (width, height), img.tostring())

        img = gamma_correct(img)

        return img 
开发者ID:OpenGeoscience,项目名称:geonotebook,代码行数:39,代码来源:provider.py


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