GithubHelp home page GithubHelp logo

python-quadkey's Introduction

This is a small python library to work with quadkeys in a fast way

installing

pip install git+https://github.com/CartoDB/python-quadkey.git

how to use it

import quadkey
print(quadkey.lonlat2quadint(-73.969558715820312, 40.757678985595703)
1013670064444553679

Aknowledgments

The fast technique for quadkey encodig/decoding is taken from https://github.com/yinqiwen/geohash-int

Available Methods

lonlat2quadint(lon, lat)

  • Input: longitude, latitude in WGS84 (SRID 4326) coordinates in degrees
  • Output: quadint value

webmercator2quadint(x, y)

  • Input: web mercator coordinates (SRID 3857)
  • Output: quadint value

Functions to handle tiles (defined by a quadint value and a zoom level)

tile2range(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: minimum and maximum quadint values

tile2bbox(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: bounding box defined by minimum longitude, minimum latitude, maximum longitude and maximum latitude (WGS84)

tile2bbox_webmercator(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: bounding box defined by minimum x, minimum y, maximum x, maximum y (Web Mercator)

tile_center(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: longitude and latitude of the tile center (WGS84)

tile_center_webmercator(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: longitude and latitude of the tile center (Webmercator)

tile_children(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: quadint values of the 4 children of the tile of level zoom+1

tile_mask(quadint, zoom)

  • Input: zoom level
  • Output: quadint mask to select tiles of the level (with bitwise AND)

Conversion of tile representation between quadint, zoom and x, y zoom:

xyz2quadint(x, y, zoom)

  • Input: x, y, z coordinates of the tile
  • Output: quadint value of the tile

tile2xyz(quadint, zoom)

  • Input: quadint value and zoom level
  • Output: x, y, z of the tile

Obtaning the list of tiles that intersect a web mercator rectangle, given a maximum tile zoom level.

tiles_intersecting_webmercator_box(max_zoom, xmin, ymin, xmax, ymax)

python-quadkey's People

Contributors

javisantana avatar jgoizueta avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.