本文整理匯總了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