Skip to content

Instantly share code, notes, and snippets.

@sjsrey
Last active October 10, 2019 13:41
Show Gist options
  • Save sjsrey/6d420dd4c59ec86d52ceeb2fb078f8ed to your computer and use it in GitHub Desktop.
Save sjsrey/6d420dd4c59ec86d52ceeb2fb078f8ed to your computer and use it in GitHub Desktop.
alpha clipping bug
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1.029128626334328445e+01 1.365816287575282217e+01
1.195670482003673030e+01 1.471579988333618516e+01
1.897682175711089059e+01 1.382784831636707068e+01
1.113533517690262187e+01 1.601637670660973711e+01
1.462906854496425879e+01 1.375513889320493455e+01
1.100534935018026950e+01 1.907425742182736172e+01
1.884919710605745280e+01 1.251931919170242402e+01
1.045159564037694544e+01 1.884556815316026501e+01
1.158277314162118188e+01 1.621805205103852998e+01
1.660235416968842159e+01 1.519387455027133882e+01
1.756838227823502763e+01 1.380998327257449354e+01
1.723869420902103755e+01 1.023414275142773633e+01
1.698404619430929685e+01 1.205643537016283773e+01
1.204673219358900660e+01 1.956061924357363324e+01
1.499043599656454795e+01 1.145301772049807987e+01
1.708209028469097035e+01 1.402870211122390209e+01
1.589573166403873117e+01 1.465951259545013485e+01
1.582136241533121179e+01 1.050353084733463938e+01
1.147080242126983762e+01 1.457617246833424751e+01
1.758407826011995922e+01 1.616417827489364711e+01
1.717312085194632232e+01 1.270418505208493087e+01
1.332203009720132414e+01 1.425581912363055181e+01
1.946907894574708564e+01 1.314421552600851228e+01
1.704857801949855656e+01 1.035906345122783456e+01
1.339986530464298298e+01 1.939053117658754388e+01
1.504669045194645172e+01 1.661936061061076941e+01
1.287454403444879247e+01 1.808811930471991758e+01
1.959718858566854038e+01 1.439118605832049980e+01
1.264476504038637827e+01 1.545316648830846162e+01
1.834661710432902737e+01 1.052062362263327344e+01
1.161168727172857018e+01 1.042609481502864099e+01
1.005375702449195963e+01 1.378849222938711527e+01
1.977190244539414721e+01 1.168635731842035419e+01
1.689198869339618625e+01 1.553627001092079851e+01
1.293537450428770796e+01 1.094741669487824609e+01
1.011649833845572388e+01 1.463882930247080161e+01
1.959407900074536002e+01 1.578353082466281521e+01
1.298147190913113747e+01 1.565679636207205760e+01
1.659623645664111891e+01 1.614805175330319997e+01
1.486084931012926091e+01 1.014642950294869905e+01
1.190328905291297446e+01 1.891832213780040206e+01
1.450627033074235683e+01 1.269156576659019464e+01
1.598140358238145708e+01 1.550667220541790670e+01
1.946557544983048871e+01 1.954205825748656622e+01
1.592717374102223182e+01 1.170862929232374583e+01
1.260927308699297811e+01 1.031667428830976263e+01
1.438377320701443196e+01 1.123894736922024506e+01
1.648343788504370622e+01 1.002621532387114200e+01
1.318416688225100941e+01 1.381532057344131914e+01
1.302815156398435548e+01 1.306160001112482938e+01
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import libpysal
import numpy
import geopandas
from shapely.geometry import Point, Polygon
get_ipython().run_line_magic('matplotlib', 'inline')
# In[2]:
points = numpy.loadtxt('alphapoints.txt')
points.shape
# In[3]:
w_test = libpysal.weights.Voronoi(points)
# In[4]:
w_test.n
# In[5]:
p_gdf = geopandas.GeoDataFrame(geometry=[Point(point) for point in points])
# In[6]:
regions, generators = libpysal.cg.voronoi.voronoi_frames(points)
# In[7]:
a_regions = libpysal.cg.voronoi.clip_voronoi_frames_to_extent(regions, generators, clip='ahull')
# In[8]:
ax = regions.plot(color='white', edgecolor='black')
a_regions.plot(ax=ax, alpha=0.2, color='green')
generators.plot(ax=ax, color='red')
# In[ ]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment