Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: float() argument must be a string or a number, not 'Point' #1294

Open
LuYan5203 opened this issue Jan 4, 2024 · 1 comment
Open

Comments

@LuYan5203
Copy link

LuYan5203 commented Jan 4, 2024

Hello, I used this a few months ago, but now it always has errors, how can I do to solve this problem?
I hope to receive your reply, thanks!

TypeError                                 Traceback (most recent call last)
<ipython-input-20-3f025cdcffdd> in <module>
      1 # 创建 Queen 邻接矩阵
----> 2 wq = weights.Queen.from_dataframe(gdf)
      3 wq.transform = 'r'  # 标准化矩阵

E:\Anaconda\Anaconda\lib\site-packages\libpysal\weights\contiguity.py in from_dataframe(cls, df, geom_col, **kwargs)
    337         elif isinstance(ids, str):
    338             ids = df.get(ids).tolist()
--> 339         w = cls.from_iterable(df[geom_col].tolist(), ids=ids, id_order=id_order, **kwargs)
    340         return w
    341 

E:\Anaconda\Anaconda\lib\site-packages\libpysal\weights\contiguity.py in from_iterable(cls, iterable, sparse, **kwargs)
    283         """
    284         new_iterable = iter(iterable)
--> 285         w = cls(new_iterable, **kwargs)
    286         if sparse:
    287             w = WSP.from_W(w)

E:\Anaconda\Anaconda\lib\site-packages\libpysal\weights\contiguity.py in __init__(self, polygons, **kw)
    201         first_shape = next(iter(backup))
    202         if isinstance(first_shape, point_type):
--> 203             polygons, vertices = voronoi_frames(get_points_array(polygons))
    204             polygons = list(polygons.geometry)
    205         neighbors, ids = _build(polygons, criterion=criterion, 

E:\Anaconda\Anaconda\lib\site-packages\libpysal\cg\voronoi.py in voronoi_frames(points, radius, clip)
    238 
    239     """
--> 240     regions, vertices = voronoi(points, radius=radius)
    241     regions, vertices = as_dataframes(regions, vertices, points)
    242     if clip:

E:\Anaconda\Anaconda\lib\site-packages\libpysal\cg\voronoi.py in voronoi(points, radius)
     55            [ -9.22691341,  -4.58994414]])
     56     """
---> 57     vor = Voronoi(points)
     58     return voronoi_regions(vor, radius=radius)
     59 

qhull.pyx in scipy.spatial.qhull.Voronoi.__init__()

E:\Anaconda\Anaconda\lib\site-packages\numpy\core\_asarray.py in ascontiguousarray(a, dtype, like)
    226         return _ascontiguousarray_with_like(a, dtype=dtype, like=like)
    227 
--> 228     return array(a, dtype, copy=False, order='C', ndmin=1)
    229 
    230 

TypeError: float() argument must be a string or a number, not 'Point'
@Oluwajuwon-O
Copy link

It appears you are convert an object to float.
I think you should inspect the dataframe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants