python - Pysal doesn't recognize some polygon neighbors -
i'm using pysal tool analyzing several shapefiles (type polygon) contain results of segmentations done in qgis.
i load shapefile using
segshp = pysal.weights.queen.from_shapefile(vect)
being vect name of corresponding shapefile.
the problem when in neighbors dictionary, if polygon shares less 2 pixels not considered neighbor. let me show bit better:
using arcgis, calculate polygon neighbors (analysis tools --> proximity ---> polygon neighbors), , example, polygon 1227 has 4 neighbors shown in image.
but when loading in python using pysal, polygon 1227 has 3 neighbors , 1 missing 3307, shares 2 pixel border. same happens other polygons share 1 or 2 pixels. "threshold" of 2 pixels have seen analyzing polygons.
is there anyway of changing "threshold" in order consider neighbors? i've seen in pysal documentation , thought maybe it's related command
pysal.weights.user.min_threshold_dist_from_shapefile
or similar, got no idea.
i tried pysal.weights.rook... option, recognizes less neighbors , finds more islands.
thanks lot
thanks @charles.
indeed seems problem. checking vertices, although polygon 1227 , 3307 share common border, don't share vertices. once edited them manually , corrected small difference in coordenates of new vertices, pysal tool recognize them neighbors. checking geometry of shapefile not generates invalid geometries, neither in arcgis or qgis.
i'll try figure way create "missing" vertices in these cases, can "fix" geometry before pysal line (any ideas matter welcome).
anyway, , respecting original question issue has been solved.
Comments
Post a Comment