Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

A Python 3 package for classifying geolocation data.

Project Description
# polypoint
A Python 3 package for classifying geolocation data.

## Installation
```
pip3 install polypoint
```

## Example Use
Unless you provide a correctly formatted XML sheet (see states.xml for an example), polypoint defaults to using the 50 states of America as its polygons.
```
from polypoint import polypoint
classifier = polypoint.PolygonClassifier()
classifier.initialize()
# point_list containing tuples of latitude and longitude of the form:
# [(39.962245, -83.000647), (42.659829, -73.781339), ... ]
point_list = [(39.962245, -83.000647), (42.659829, -73.781339)]

# returns a list of polygon indices of the form:
# [34, 31, ... ]
results = classifier.match_points_to_polygon(point_list)
print(results)

# returns a list of polygon names of the form:
# ['Ohio', 'New York', ... ]
results_string = classifier.get_polygon_names(results)
print(results_string)
```

## Public Interface

`classifier.match_points_to_polygon(point_list)` accepts a list of coordinates to classify and returns a Numpy array of integers which are indices in `classifier.conf.name_list`. These integers are easily converted to polygon names with the `classifier.get_polygon_names(result_list)` method.

`classifier.get_polygon_names(result_list)` accepts a list of integers and returns a list with the corresponding strings from the list `classifier.conf.name_list`

## Initialization and Configuration

Each PolygonClassifier instance has a Configuration class (see config.py) as an instance variable, accessible as `classifier.conf`

There are two configuration initialization options for a classifier
```
classifier.initialize()
```
and
```
classifier.initialize_min()
```
`classifier.initialize()` will perform a full initialization of the classifier configuration. See the Configuration class in the config.py file. Some of more important options are `parallel_enabled`, `num_cpu`, `parallel_limit`, and `trimmed_polygons`.

`classifier.initialize_min()` will perform a minimal initialization of the classifier configuration, with no optimization and using no parallel processing. Useful if only working with small lists at once.

`classifier.conf.parallel_enabled` is a boolean that will enable or disable parallel computation on the input.

`classifier.conf.num_cpu` is an integer value for the number of cores your processor has. This controls how many processes are started to perform computation on the input. If left unconfigured, this defaults to the number of detected cores in your processor. (Note that this may read the number of virtual cores)

`classifier.conf.parallel_limit` is an integer lower limit on the size of the input that triggers parallel computation. For example, if set to 1000 then the input list must be of size greater than 1000 to start parallel computation. For lists of size 1000 or less, the result will be computed sequentially. Defaults to 0 (meaning that if `parallel_enabled` is set to `True`, all input will use multiple processes). If you are repeatedly inputting small lists, it may be worth disabling parallel computation or finding at what list size multiprocessing is faster/slower and setting that value here.

`classifier.conf.trimmed_polygons` is a list of polygons corresponding to the classifying polygons. For example, if the 50 states of America are being used, this list will have 50 corresponding polygons. All of the trimmed polygons will be contained by the original polygons and are used to speed up the search. See below for examples. Blue is the original polygon and red is the trimmed polygon.

![Georgia with trimmed interior polygon](https://raw.githubusercontent.com/josephacall/polypoint/dev/images/georgia_with_trimmed.png "Georgia with trimmed interior polygon")

![Georgia with trimmed interior polygon](https://raw.githubusercontent.com/josephacall/polypoint/dev/images/new_york_with_trimmed.png "New York with trimmed interior polygon")

![Texas with trimmed interior polygon](https://raw.githubusercontent.com/josephacall/polypoint/dev/images/texas_with_trimmed.png "Texas with trimmed interior polygon")

### MIT License
Release History

Release History

This version
History Node

0.15

History Node

0.14

History Node

0.13

History Node

0.12

History Node

0.11

History Node

0.10

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
polypoint-0.15.tar.gz (39.9 kB) Copy SHA256 Checksum SHA256 Source May 10, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting