GithubHelp home page GithubHelp logo

fagan2888 / py-visvalingam-whyatt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pkerpedjiev/py-visvalingam-whyatt

0.0 1.0 0.0 239 KB

Python implementation of Visvalingam and Whyatt's algorithm for reducing the complexity of poly-lines

Python 100.00%

py-visvalingam-whyatt's Introduction

Visvalingam-Whyatt polyline simplification

Efficient Pure Python implementation of Visvalingam and Whyatt's algorithm for reducing the complexity of poly-lines. Also includes precision decimation to reduce file sizes if desired.

Works with GDAL OGRGeometry LINESTRING, POLYGON and MULTIPOLYGON objects as well as lists of vertices.

This method ranks the verticies by their importance to the shape (how much removing the affects the area) in a non-destructive manner. Once the ranking has been done, filtering of points is ultra fast (just one numpy mask operation).

However, even for just one filtering operation, this method seems to be faster than Ramer-Douglas-Peucker.

from polysimplify import VWSimplifier
import numpy as np
from time import time

n = 5000
thetas = np.linspace(0,2*np.pi,n)
pts = np.array([[np.sin(x),np.cos(x)] for x in thetas])

start=time()
simplifier = VWSimplifier(pts)
VWpts = simplifier.from_number(n/100)
end = time() 
print "Visvalingam: reduced to %s points in %03f seconds" %(len(VWpts),end-start)
#50 points in .131 seconds on my computer


from rdp import rdp
start=time()
RDPpts = rdp(pts,epsilon=.00485) #found by trail and error
end = time()
print "Ramer-Douglas-Peucker: to %s points in %023 seconds" %(len(RDPpts),end-start)
#40 points in 1.35 seconds on my computer

py-visvalingam-whyatt's People

Contributors

permafacture 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.