@@ -928,7 +928,11 @@ def polygon_topology(self, **kwargs) -> None:
928928 # Create column named ``touching``. Each element
929929 # is an empty list
930930 length_range = range (self ._df .__len__ ())
931- self ._df ['touching' ] = pd .Series ([] for _ in length_range )
931+ self ._df ["touching" ] = pd .Series (
932+ [[] for _ in length_range ],
933+ index = self ._df .index ,
934+ dtype = object ,
935+ )
932936
933937 # Iterate over all possible pairs of polygons in the data
934938 for i , j in itertools .combinations (length_range , 2 ):
@@ -943,8 +947,8 @@ def polygon_topology(self, **kwargs) -> None:
943947 # also add i's osbg to j's
944948 # ``touching`` column
945949 if algs ._is_touching (poly_i , poly_j ):
946- self ._df [ 'touching' ][ i ].append (osgb_j )
947- self ._df [ 'touching' ][ j ].append (osgb_i )
950+ self ._df . at [ i , "touching" ].append (osgb_j )
951+ self ._df . at [ j , "touching" ].append (osgb_i )
948952
949953 # If polygon i intersects polygon j, then the
950954 # _is_touching function will throw a ValueError.
@@ -993,15 +997,19 @@ def _polygon_within_hole(self) -> None:
993997 # Create column named ``poly_within_hole``. Each element
994998 # is an empty list
995999 length_range = range (self ._df .__len__ ())
996- self ._df ['poly_within_hole' ] = pd .Series ([] for _ in length_range )
1000+ self ._df ["poly_within_hole" ] = pd .Series (
1001+ [[] for _ in length_range ],
1002+ index = self ._df .index ,
1003+ dtype = object ,
1004+ )
9971005
9981006 # Iterate over the cartesian product of polygons
9991007 for i , j in itertools .product (length_range , length_range ):
10001008 if i != j and self ._df ['interiors' ][i ]:
10011009
10021010 # If polygon i has interiors, then check if polygon j
10031011 # touches polygon i
1004- touches = self ._df [ ' osgb' ][ j ] in self ._df [ 'touching' ][ i ]
1012+ touches = self ._df . at [ j , " osgb" ] in self ._df . at [ i , "touching" ]
10051013
10061014 # Now iterate over the interiors of polygon i
10071015 for item in self ._df ['polygon' ][i ].interiors :
@@ -1010,10 +1018,8 @@ def _polygon_within_hole(self) -> None:
10101018 # If the interior both touchs and contains j, then we know
10111019 # j exists within a hole inside i
10121020 # We make a note of this in the `poly_within_hole` column
1013- if item_poly .contains (self ._df ['polygon' ][j ]) and touches :
1014- self ._df ['poly_within_hole' ][i ].append (
1015- self ._df ['osgb' ][j ]
1016- )
1021+ if item_poly .contains (self ._df .at [j , "polygon" ]) and touches :
1022+ self ._df .at [i , "poly_within_hole" ].append (self ._df .at [j , "osgb" ])
10171023
10181024 def _polygon_buffer (self ) -> None :
10191025 for i , polygon in enumerate (self ._df ['polygon' ]):
0 commit comments