I have a gdf with this characteristics:
gdf.info()
<class 'geopandas.geodataframe.GeoDataFrame'>
Int64Index: 405943 entries, 0 to 405942
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Mz 405943 non-null object
1 Area_km2 405943 non-null float64
2 UBIGEO 405943 non-null object
3 IDPROV 405943 non-null object
4 CCDD 405943 non-null object
5 PobMz 405943 non-null float64
6 geometry 405943 non-null geometry
dtypes: float64(2), geometry(1), object(4)
memory usage: 40.9+ MB
So, first I want to get centroids from it:
cent=gdf.centroid
cent.head()
0 POINT (546598.404 8580848.223)
1 POINT (537595.600 8588489.910)
2 POINT (534681.734 8586405.771)
3 POINT (558020.684 8571566.834)
4 POINT (535966.243 8592514.133)
dtype: geometry
cent.crs
<Projected CRS: EPSG:32718>
Name: WGS 84 / UTM zone 18S
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: Between 78°W and 72°W, southern hemisphere between 80°S and equator, onshore and offshore. Argentina. Brazil. Chile. Colombia. Ecuador. Peru.
- bounds: (-78.0, -80.0, -72.0, 0.0)
Coordinate Operation:
- name: UTM zone 18S
- method: Transverse Mercator
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
But when I want to do a Spatial Join with another gdf:
trying = gpd.sjoin(cent, blocks, how="left")
I get this message:
ValueError: 'left_df' should be GeoDataFrame, got <class 'geopandas.geoseries.GeoSeries'>
How should be the proper code?