<jupyter_start><jupyter_text>Find concave and convex vertices on a polygon boundary  create a concave hull polygon<jupyter_code>np.random.seed(seed=456)
x = np.random.normal(100000,500, 1000)
y = np.random.normal(100000, 500, 1000)
coords = np.array(list(zip(x, y)))
ch = concavity.concave_hull(coords, 20)
ch<jupyter_output><empty_output><jupyter_text>The ```find_concave_vertices``` and ```find_concave_vertices``` functions take a polygon, an angle_threshold as the minimum angle above which a vertex is in a concave/convex location and a filter type that determines if the function outputs all point above the angle threshold or will attempt to locate the peak concave/convex vertices. the output type can be either ageopandas GeoDataFrame or a list of vertices and the angle of the two edges they connect Here we choose to output all the concave/convex:<jupyter_code>concave_df = concavity.find_concave_vertices(ch,0, filter_type ='all')
convex_df = concavity.find_convex_vertices(ch,0, filter_type ='all')
concavity.plot_vertices(ch, concave_df, convex_df)<jupyter_output><empty_output><jupyter_text>To make a less obvious example - let's smooth our polygon and try again<jupyter_code>geom = gaussian_smooth_geom( ch)
geom
concave_df = concavity.find_concave_vertices(geom,0, filter_type ='all')
convex_df = concavity.find_convex_vertices(geom,0, filter_type ='all')
concavity.plot_vertices(geom, concave_df, convex_df)<jupyter_output><empty_output><jupyter_text>Here we let the algorithm detect only the peak concave and convex vertices<jupyter_code>concave_df = concavity.find_concave_vertices(geom,0, filter_type ='peak')
convex_df = concavity.find_convex_vertices(geom,0, filter_type ='peak')
concavity.plot_vertices(geom, concave_df, convex_df)<jupyter_output><empty_output><jupyter_text>We can smooth the angles by using the convovle boolean argument and refine even further the vertices that will be marked as peaks<jupyter_code>concave_df = concavity.find_concave_vertices(geom,0, filter_type ='peak', convolve = True)
convex_df = concavity.find_convex_vertices(geom,0, filter_type ='peak', convolve = True)
concavity.plot_vertices(geom, concave_df, convex_df)<jupyter_output><empty_output><jupyter_text>Use the angle threshold argument to limit the angles above which a vertex is considered convex/concave:<jupyter_code>concave_df = concavity.find_concave_vertices(geom,angle_threshold=10, filter_type ='peak')
convex_df = concavity.find_convex_vertices(geom,angle_threshold=10, filter_type ='peak')
concavity.plot_vertices(geom, concave_df, convex_df)
concave_df = concavity.find_concave_vertices(geom,35, filter_type ='all')
convex_df = concavity.find_convex_vertices(geom,35, filter_type ='all')
concavity.plot_vertices(geom, concave_df, convex_df)<jupyter_output>/media/ml/ex1/my_repos/concavity/venv/lib/python3.6/site-packages/geopandas/plotting.py:418: UserWarning: The GeoDataFrame you are attempting to plot is empty. Nothing has been displayed.
  "empty. Nothing has been displayed.", UserWarning)
{'fraction_non_alphanumeric': 0.09099933818663138, 'fraction_numerical': 0.01753805426869623, 'mean_word_length': 8.216463414634147, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '334106', 'license': 'MIT', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1012, 'n_words': 255, 'path': 'examples/find_concave_and_convex_vertices.ipynb', 'repo_name': 'ajtritt/concavity', 'size': '3022'}