本文整理汇总了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))
示例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)
示例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