How to use the mercantile.lnglat function in mercantile

To help you get started, we’ve selected a few mercantile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_lnglat_xy_roundtrip():
    lnglat = (-105.0844, 40.5853)
    roundtrip = mercantile.lnglat(*mercantile.xy(*lnglat))
    for a, b in zip(roundtrip, lnglat):
        assert round(a - b, 7) == 0
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_lnglat_truncate():
    xy = (-28366731.739810849, -1655181.9927159143)
    assert mercantile.lnglat(*xy, truncate=True) == (-180, -14.704620000000013)
github GoogleCloudPlatform / earth-ml / server-bak / landcover.py View on Github external
def tile_to_blocks(tile_x, tile_y, zoom, year):
  tile = mercantile.xy_bounds(tile_x, tile_y, zoom)
  west, north = mercantile.lnglat(tile.left, tile.top)
  east, south = mercantile.lnglat(tile.right, tile.bottom)

  blocks = []
  for block in mercantile.tiles(west, south, east, north, config.block_zoom):
    bounds = mercantile.bounds(block)
    block = {
      'id': '{}-{}-{}'.format(block.x, block.y, year),
      'x': block.x,
      'y': block.y,
      'year': year,
      'north': bounds.north,
      'east': bounds.east + 0.1,
      'south': bounds.south - 0.1,
      'west': bounds.west,
    }
    blocks += [block]
github GoogleCloudPlatform / earth-ml / server / submit.py View on Github external
def tile(x, y, zoom, start_year, end_year, dry_run=False):
  xy_bounds = mercantile.xy_bounds(x, y, zoom)
  west, north = mercantile.lnglat(xy_bounds.left, xy_bounds.top)
  east, south = mercantile.lnglat(xy_bounds.right, xy_bounds.bottom)
  return bounds(west, south, east, north, start_year, end_year, dry_run)
github GoogleCloudPlatform / earth-ml / server-bak / landcover.py View on Github external
def tile_to_blocks(tile_x, tile_y, zoom, year):
  tile = mercantile.xy_bounds(tile_x, tile_y, zoom)
  west, north = mercantile.lnglat(tile.left, tile.top)
  east, south = mercantile.lnglat(tile.right, tile.bottom)

  blocks = []
  for block in mercantile.tiles(west, south, east, north, config.block_zoom):
    bounds = mercantile.bounds(block)
    block = {
      'id': '{}-{}-{}'.format(block.x, block.y, year),
      'x': block.x,
      'y': block.y,
      'year': year,
      'north': bounds.north,
      'east': bounds.east + 0.1,
      'south': bounds.south - 0.1,
      'west': bounds.west,
    }
    blocks += [block]
  return blocks
github GoogleCloudPlatform / earth-ml / server / submit.py View on Github external
def tile(x, y, zoom, start_year, end_year, dry_run=False):
  xy_bounds = mercantile.xy_bounds(x, y, zoom)
  west, north = mercantile.lnglat(xy_bounds.left, xy_bounds.top)
  east, south = mercantile.lnglat(xy_bounds.right, xy_bounds.bottom)
  return bounds(west, south, east, north, start_year, end_year, dry_run)