I want to create a simple spatial join between points and polygons using GeoPandas but I think GeoPandas has bug?
GeoPandas code:
from geopandas import gpd
import geopandas
points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc
polys = geopandas.GeoDataFrame.from_file('polygons.shp')
pointInPoly = gpd.sjoin(points, polys, how='left',op='within')
Error :
Traceback (most recent call last):
File "/home/username/testshapely/sumpointsinsidepolygon/testgeo.py", line 7, in <module>
pointInPoly = gpd.sjoin(points, polys, how='left',op='within')
File "/usr/local/lib/python2.7/dist-packages/geopandas/tools/sjoin.py", line 57, in sjoin
r_idx = np.concatenate(idxmatch.values)
ValueError: need at least one array to concatenate
And if I change the imports with the some code:
import geopandas
import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame, read_file
from geopandas.tools import sjoin
from shapely.geometry import Point, mapping,shape
import pandas as gpd
I get the following error:
pointInPoly = gpd.sjoin(points, polys, how='left',op='within')
AttributeError: 'module' object has no attribute 'sjoin'
Any ideas why?
import pandas as gpd