Creating a rule – only one point inside a polygon
A long time ago in GIS history, not having more than one point present in a polygon was super important because one point per polygon was the standard way to demonstrate a topologically clean polygon with its associated attribute and ID. Today, it is still important for many other reasons, such as assigning attributes to polygons based on points inside a polygon. We must perform a spatial join between the polygon and point to assign these valuable attributes. If two points are located in one polygon, which attributes do you use? This recipe is about creating a rule to check your data beforehand to ensure that only one point is located in each polygon. If this test fails, you will get a list or errors; if it passes, the test returns True
.
Getting ready
Data again plays the central role here, so check that your /ch09/geodata/
folder is ready with two input Shapefiles containing topo_polys.shp
and topo_points.shp
. The Shapely library performs...