nypl-spacetime / map-vectorizer

An open-source map vectorizer
MIT License
648 stars 57 forks source link

improve simplify function #12

Open mgiraldo opened 11 years ago

mgiraldo commented 11 years ago

Explore the possibility of making R unnecessary by implementing a Ramer–Douglas–Peucker or Visvalingam algorithm directly in Python. A Python implementation done by @migurski: https://github.com/migurski/bloch

See line 223: https://github.com/NYPL/map-vectorizer/blob/master/vectorize_map.py#L223 and simplify_map.R: https://github.com/NYPL/map-vectorizer/blob/master/simplify_map.R

via @albertsun

tlevine commented 9 years ago

Have you looked at https://pypi.python.org/pypi/rdp/?

mgiraldo commented 9 years ago

had not seen it. seems pretty new. will look into it

mgiraldo commented 9 years ago

adding contents of #21:

I originally used R because I found code that reduces the amount of corners in a geographic polygon: http://rpubs.com/geospacedman/alphasimple

The function in the vectorizer is: https://github.com/NYPL/map-vectorizer/blob/9b9129b9d135c89b350700549794e7d0f2348af2/vectorize_map.py#L227

and the R code: https://github.com/NYPL/map-vectorizer/blob/9b9129b9d135c89b350700549794e7d0f2348af2/simplify_map.R

Ideally, we would eliminate R and have python code that produces the same output as R (one shapefile for each polygon that was simplified that is within the area threshold).

A shapefile-per-polygon is produced (thousands!) because it was the only way I could pass data from python-to-R-and-back but was also useful to find the average color of the polygon.

tlevine commented 9 years ago

http://stackoverflow.com/questions/26303878/alpha-shapes-in-3d http://www.mrzv.org/software/dionysus/python/alphashapes.html http://www.mrzv.org/software/dionysus/python/overview.html#python-bindings http://doc.cgal.org/latest/Alpha_shapes_2/index.html http://stackoverflow.com/questions/17553035/draw-a-smooth-polygon-around-data-points-in-a-scatter-plot-in-matplotlib http://repositorium.sdum.uminho.pt/bitstream/1822/6429/1/ConcaveHull_ACM_MYS.pdf

tlevine commented 9 years ago

http://stackoverflow.com/questions/83593/is-there-an-efficient-algorithm-to-generate-a-2d-concave-hull

tlevine commented 9 years ago

http://www.cis.rit.edu/people/faculty/kerekes/pdfs/AIPR_2007_Gurram.pdf https://patentscope.wipo.int/search/en/detail.jsf?docId=WO2008107859