I am working with some geodata. I want to get a point object from the latitude and longitude that I already have. My code looks as follows:
for i in range(len(map_polygon)):
x = map_polygon.at[i, 'lon']
y = map_polygon.at[i, 'lat']
map_polygon.at[i, 'point'] = Point(x, y)
However, I am getting the following error: RecursionError: maximum recursion depth exceeded in comparison
What am I doing wrong? The length of the data frame is only about 20k rows.
Thank you!
PS I have attached the whole error message below:
map_polygon.at[i, 'point'] = Point(x, y)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 2167, in __setitem__
return super().__setitem__(key, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 2118, in __setitem__
self.obj._set_value(*key, value=value, takeable=self._takeable)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/frame.py", line 3278, in _set_value
self.loc[index, col] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 692, in __setitem__
iloc._setitem_with_indexer(indexer, value, self.name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 1635, in _setitem_with_indexer
self._setitem_with_indexer_split_path(indexer, value, name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 1720, in _setitem_with_indexer_split_path
self._setitem_single_column(loc, value, pi)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/indexing.py", line 1813, in _setitem_single_column
ser._mgr = ser._mgr.setitem(indexer=(pi,), value=value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 568, in setitem
return self.apply("setitem", indexer=indexer, value=value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/managers.py", line 427, in apply
applied = getattr(b, f)(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 967, in setitem
return self.astype(dtype).setitem(indexer, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 967, in setitem
return self.astype(dtype).setitem(indexer, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 967, in setitem
return self.astype(dtype).setitem(indexer, value)
[Previous line repeated 977 more times]
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/internals/blocks.py", line 966, in setitem
dtype, _ = maybe_promote(np.array(value).dtype)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/shapely/geometry/point.py", line 111, in array_interface
if self.is_empty:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/shapely/geometry/base.py", line 699, in is_empty
return (self._geom is None) or bool(self.impl['is_empty'](self))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/shapely/predicates.py", line 25, in __call__
return self.fn(this._geom)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/shapely/geos.py", line 583, in errcheck_predicate
if result == 2:
RecursionError: maximum recursion depth exceeded in comparison