GithubHelp home page GithubHelp logo

fagan2888 / pyqtree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpatokal/pyqtree

0.0 0.0 0.0 86 KB

A pure Python quad tree spatial index for GIS or rendering usage

License: MIT License

HTML 60.66% Python 39.34%

pyqtree's Introduction

Pyqtree

Pyqtree is a pure Python spatial index for GIS or rendering usage. It stores and quickly retrieves items from a 2x2 rectangular grid area, and grows in depth and detail as more items are added. The actual quad tree implementation is adapted from Matt Rasmussen's compbio library and extended for geospatial use.

Platforms

Python 2 and 3.

Dependencies

Pyqtree is written in pure Python and has no dependencies.

Installing It

Installing Pyqtree can be done by opening your terminal or commandline and typing:

pip install pyqtree

Alternatively, you can simply download the "pyqtree.py" file and place it anywhere Python can import it, such as the Python site-packages folder.

Example Usage

Start your script by importing the quad tree.

from pyqtree import Index

Setup the spatial index, giving it a bounding box area to keep track of. The bounding box being in a four-tuple: (xmin, ymin, xmax, ymax).

spindex = Index(bbox=(0, 0, 100, 100))

Populate the index with items that you want to be retrieved at a later point, along with each item's geographic bbox.

# this example assumes you have a list of items with bbox attribute
for item in items:
    spindex.insert(item, item.bbox)

Then when you have a region of interest and you wish to retrieve items from that region, just use the index's intersect method. This quickly gives you a list of the stored items whose bboxes intersects your region of interests.

overlapbbox = (51, 51, 86, 86)
matches = spindex.intersect(overlapbbox)

There are other things that can be done as well, but that's it for the main usage!

More Information:

License:

This code is free to share, use, reuse, and modify according to the MIT license, see LICENSE.txt.

Credits:

  • Karim Bahgat (2015)
  • Joschua Gandert (2016)

Changes

0.25.0 (2016-06-22)

  • Misc user contributions and bug fixes

0.24.0 (2015-06-18)

  • Previous stable PyPI version.

pyqtree's People

Contributors

creamycookie avatar jpatokal avatar karimbahgat avatar lumbric avatar pailakka avatar rickarmstrong 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.