Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import geopandas
- #bus stop dataset
- gdf = geopandas.GeoDataFrame(
- bus, geometry=geopandas.points_from_xy(bus.stop_location_longitiude, bus.stop_location_latitiude))
- #columns
- #stop_name stop_location_longitiude stop_location_latitiude geometry
- #Country polygon
- import geopandas as gpd
- data_poly = gpd.read_file("Country_community_file.geojson")
- """Index(['Name', 'description', 'altitudeMode', 'CNAME_E', 'CNAME_A', 'OBJECTID',
- 'LABEL_E', 'LABEL_A', 'C_PREFIX_E', 'C_PREFIX_A', 'COMMUNITY_',
- 'COMMUNITY1', 'DGIS_ID', 'COMM_NUM', 'NDGIS_ID', 'SHAPE_AREA',
- 'SHAPE_LEN', 'geometry'],
- dtype='object')"""
- import geopandas as gpd
- joined_gdf = gpd.sjoin(gdf, data_poly, op='within')
- Error
- ---------------------------------------------------------------------------
- AttributeError Traceback (most recent call last)
- <ipython-input-49-145cab3e1349> in <module>
- 1 import geopandas as gpd
- ----> 2 joined_gdf = gpd.sjoin(gdf, data_poly, op='within')
- /opt/anaconda3/lib/python3.7/site-packages/geopandas/tools/sjoin.py in sjoin(left_df, right_df, how, op, lsuffix, rsuffix)
- 134 # tree_idx_df == 'left'
- 135 idxmatch = right_df.geometry.apply(lambda x: x.bounds).apply(
- --> 136 lambda x: list(tree_idx.intersection(x)) if not x == () else []
- 137 )
- 138 idxmatch = idxmatch[idxmatch.apply(len) > 0]
- /opt/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
- 3846 else:
- 3847 values = self.astype(object).values
- -> 3848 mapped = lib.map_infer(values, f, convert=convert_dtype)
- 3849
- 3850 if len(mapped) and isinstance(mapped[0], Series):
- pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
- /opt/anaconda3/lib/python3.7/site-packages/geopandas/tools/sjoin.py in <lambda>(x)
- 134 # tree_idx_df == 'left'
- 135 idxmatch = right_df.geometry.apply(lambda x: x.bounds).apply(
- --> 136 lambda x: list(tree_idx.intersection(x)) if not x == () else []
- 137 )
- 138 idxmatch = idxmatch[idxmatch.apply(len) > 0]
- AttributeError: 'NoneType' object has no attribute 'intersection'
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement