Error when joinned two GeoDataFrame
See original GitHub issueHy everyone,
I have this first gdf:
| DATA | OCCUR | geometry
2005-01-01 | PROPERTY CRIMES | POINT (-38.5554 -3.73784)
2005-01-01 | PROPERTY CRIMES | POINT (-38.5606 -3.83914)
2005-01-01 | PROPERTY CRIMES | POINT (-38.5778 -3.72623)
2005-01-01 | PROPERTY CRIMES | POINT (-38.501 -3.795)
2005-01-01 | PROPERTY CRIMES | POINT (-38.4813 -3.72222)
And this second:
BAIRRO | VAL_M2_RES | geometry
PASSARE | 2424.77 | POLYGON ((-38.539819067859945 -3.7955371068432...
CAIS DO PORTO | 2627.39 | POLYGON ((-38.479334495231086 -3.7209126986722...
CIDADE 2000 | 2437.00 | POLYGON ((-38.467647506862534 -3.7496832300526...
ALTO DA BALANCA | 1784.38 | POLYGON ((-38.51716445420212 -3.76997951516616...
BARRA DO CEARA | 1551.97 | POLYGON ((-38.56887758295916 -3.70168935573553...
Then I try merge, this command:
merged_gdf = gpd.sjoin(calls_gdf, regions_gdf, how="inner", op="intersects")
But not working. Show me this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-19-879197754ba3> in <module>()
----> 1 merged_gdf = gpd.sjoin(calls_gdf, regions_gdf, how="inner", op="intersects")
2 #calls_gdf["BAIRRO"][0] = "TESTE"
C:\ProgramData\Anaconda3\lib\site-packages\geopandas\tools\sjoin.py in sjoin(left_df, right_df, how, op, lsuffix, rsuffix)
65
66 # insert the bounds in the rtree spatial index
---> 67 right_df_bounds = right_df.geometry.apply(lambda x: x.bounds)
68 stream = ((i, b, None) for i, b in enumerate(right_df_bounds))
69 tree_idx = rtree.index.Index(stream)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
2353 else:
2354 values = self.asobject
-> 2355 mapped = lib.map_infer(values, f, convert=convert_dtype)
2356
2357 if len(mapped) and isinstance(mapped[0], Series):
pandas\_libs\src\inference.pyx in pandas._libs.lib.map_infer (pandas\_libs\lib.c:66645)()
C:\ProgramData\Anaconda3\lib\site-packages\geopandas\tools\sjoin.py in <lambda>(x)
65
66 # insert the bounds in the rtree spatial index
---> 67 right_df_bounds = right_df.geometry.apply(lambda x: x.bounds)
68 stream = ((i, b, None) for i, b in enumerate(right_df_bounds))
69 tree_idx = rtree.index.Index(stream)
AttributeError: 'str' object has no attribute 'bounds'
Can you help me?
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
'left_df' should be GeoDataFrame, got <class 'geopandas. ...
GeoPandas Spatial Join Error: 'left_df' should be GeoDataFrame, got <class 'geopandas.geoseries.GeoSeries' ; 8580848.223) 1 ; 8588489.910) 2 ...
Read more >How can i use sjoin to merge two GeoDataFrames without ...
I am attempting to complete a spatial join between two GeodataFrames but this error comes up: ValueError: You are trying to merge on...
Read more >Spatial Joins
A spatial join uses binary predicates such as intersects and crosses to combine two GeoDataFrames based on the spatial relationship between their geometries ......
Read more >Why does spatial join on geodataframes return empty result?
I have two geodataframes that I want to perform a spatial join on; one is points, one is polygons. They are both dtype:...
Read more >geopandas/geopandas - Gitter
hi, i'm trying to join two geodataframes, and i'm getting this rather long key error. i have two geodataframes, with two geometry columns,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think you can also use
shapely.wkt.loadsfor this:Maybe it would be good to have some utility function for this in geopandas (or at least add an example to the docs)
It seems that your geometry column does not consist of shapely geometry objects, but of strings. Can you show the output of
type(regions_gdf.geometry[0])(and the same for the other dataframe) ?