Skip to content

straup/py-wsclustr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python bindings for ws-clustr.php (optionally running it using an EC2 instance)

If you pass it a file containing points it will return a compressed shapefile
for those points created by the Clustr application.

       http://code.flickr.com/blog/2008/10/30/the-shape-of-alpha/
       http://code.flickr.com/blog/2009/04/07/the-only-question-left-is/

       http://www.aaronland.info/weblog/2009/04/12/hammock#py-wsclustr-php

       http://github.com/straup/py-wsclustr/
       http://github.com/straup/ws-clustr/

--

Usage (from your code) :

# IMPORTANT:
#
# A backwards incompatible change the interface for this library
# was made on 20090420. If you are using an earlier version you
# should update your code accordingly. Sorry about that. The plan
# is to avoid doing that again in the future.

#
# Connecting to localhost
#

clustr = wsclustr.wsclustr(hostname='localhost')
shpfile = clustr.clustr('/path/to/points.txt', try_cache=1)

#
# Connecting to EC2
#

clustr = wsclustr.ec2(access_key='access_key', secret_key='secret_key')
clustr.startup(ami='ami-xxxxx')
    
while not clustr.ready() :
    time.sleep(5)

shpfile = clustr.clustr('/path/to/points.txt', try_cache=1)

clustr.shutdown()

--

Usage (connecting to EC2, from the command line) :

$> python examples/ec2.py -c ~/path/to/aws.cfg -A ami-xxxxx -P ~/path/to/points.txt -f ~/path/to/test.tar.gz -a 0.02 

Options:
  -h, --help            show this help message and exit
  -c CONFIG, --config=CONFIG
                        path to an ini config file
  -E ENDPOINT, --endpoint=ENDPOINT
                        the endpoint that ws-clustr is running on
  -A AMI, --ami=AMI     the name of the EC2 AMI to use
  -P POINTS, --points=POINTS
                        the path of the points file to clustrize
  -C, --try_cache       first ask ws-clustr to use a cached version of your points file
  -a ALPHA, --alpha=ALPHA
                        the size of the alpha to clustr the points file with
  -f FILENAME, --filename=FILENAME
                        the name of your shapefile
  -t, --terminate       terminate the AMI instance
  -v, --verbose         enable verbose logging

--

EC2 Notes:

If you already have a running instance of a given AMI then it will be used
rather than spinning up a new server.

At the moment, this code does not account for multiple instances of the same
AMI running. It simply uses the first one it finds.

--

Example config file:

[aws]
access_key=AMAZON_WEBSERVICES_ACCESSKEY
secret_key=AMAZON_WEBSERVICES_SECRETKEY

About

Python bindings for spinning up and using an EC2 instance running ws-clustr.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages