當前位置: 首頁>>代碼示例>>Python>>正文


Python mercantile.tiles方法代碼示例

本文整理匯總了Python中mercantile.tiles方法的典型用法代碼示例。如果您正苦於以下問題:Python mercantile.tiles方法的具體用法?Python mercantile.tiles怎麽用?Python mercantile.tiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mercantile的用法示例。


在下文中一共展示了mercantile.tiles方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: children

# 需要導入模塊: import mercantile [as 別名]
# 或者: from mercantile import tiles [as 別名]
def children(ctx, input, depth):
    """Takes a [x, y, z] tile as input and writes its children to stdout
    in the same form.

    $ echo "[486, 332, 10]" | mercantile parent

    Output:

    [243, 166, 9]
    """
    src = normalize_input(input)
    for line in iter_lines(src):
        line = line.strip()
        tiles = [json.loads(line)[:3]]
        for i in range(depth):
            tiles = sum([mercantile.children(t) for t in tiles], [])
        for t in tiles:
            output = json.dumps(t)
            click.echo(output)


# The parent command. 
開發者ID:enricofer,項目名稱:go2mapillary,代碼行數:24,代碼來源:__init__.py

示例2: _tile_results_summary

# 需要導入模塊: import mercantile [as 別名]
# 或者: from mercantile import tiles [as 別名]
def _tile_results_summary(ml_type, classes):
    print('---')
    labels = list(tile_results.values())
    all_tiles = list(tile_results.keys())
    if ml_type == 'object-detection':
        # for each class, show number of features and number of tiles
        for i, cl in enumerate(classes):
            cl_features = len([bb for l in labels for bb in l if bb[4] == i + 1])
            cl_tiles = len([l for l in labels if len(list(filter(_bbox_class(i + 1), l)))]) # pylint: disable=cell-var-from-loop
            print('{}: {} features in {} tiles'.format(cl.get('name'), cl_features, cl_tiles))
    elif ml_type == 'classification':
        class_tile_counts = list(np.sum(labels, axis=0))
        for i, cl in enumerate(classes):
            print('{}: {} tiles'.format(cl.get('name'), int(class_tile_counts[i + 1])))
    elif ml_type == 'segmentation':
        for i, cl in enumerate(classes):
            count = len([l for l in labels if class_match(ml_type, l, i + 1)])
            print('{}: {} tiles'.format(cl.get('name'), count))

    print('Total tiles: {}'.format(len(all_tiles))) 
開發者ID:developmentseed,項目名稱:label-maker,代碼行數:22,代碼來源:label.py

示例3: bbox_to_quadkeys

# 需要導入模塊: import mercantile [as 別名]
# 或者: from mercantile import tiles [as 別名]
def bbox_to_quadkeys(bbox: list, zoom: int):
    """ Find all quadkeys in a bbox """
    tiles = mercantile.tiles(bbox[0], bbox[1], bbox[2], bbox[3], int(zoom))
    quadkeys = []
    for tile in tiles:
        quadkeys.append(mercantile.quadkey(tile))

    return quadkeys 
開發者ID:hotosm,項目名稱:ml-enabler,代碼行數:10,代碼來源:__init__.py

示例4: _tile_coords

# 需要導入模塊: import mercantile [as 別名]
# 或者: from mercantile import tiles [as 別名]
def _tile_coords(self, bounds):
        """ convert mercator bbox to tile index limits """
        tfm = pyproj.Transformer.from_crs(3857, 4326, always_xy=True)
        bounds = ops.transform(tfm.transform, box(*bounds)).bounds

        # because tiles have a common corner, the tiles that cover a
        # given tile includes the adjacent neighbors.
        # https://github.com/mapbox/mercantile/issues/84#issuecomment-413113791

        west, south, east, north = bounds
        epsilon = 1.0e-10
        if east != west and north != south:
            # 2D bbox
            # shrink the bounds a small amount so that
            # shapes/tiles round trip.
            west += epsilon
            south += epsilon
            east -= epsilon
            north -= epsilon

        params = [west, south, east, north, [self.zoom_level]]
        tile_coords = [(tile.x, tile.y) for tile in mercantile.tiles(*params)]
        xtiles, ytiles = zip(*tile_coords)
        minx = min(xtiles)
        miny = min(ytiles)
        maxx = max(xtiles) 
        maxy = max(ytiles)
        return minx, miny, maxx, maxy 
開發者ID:DigitalGlobe,項目名稱:gbdxtools,代碼行數:30,代碼來源:tms_image.py


注:本文中的mercantile.tiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。