Xristos Xristoou wrote: > Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:30:48 μ.μ. UTC+2, ο χρήστης Peter Otten > έγραψε: >> Xristos Xristoou wrote: >> >> > Τη Σάββατο, 14 Ιανουαρίου 2017 - 3:43:10 μ.μ. UTC+2, ο χρήστης Peter >> > Otten έγραψε: >> >> Xristos Xristoou wrote: >> >> >> >> > i want to create a simple spatial joing using geopandas but i thing >> >> > so geopandas has bug ? >> >> >> >> Have you tried the examples on >> >> <http://geopandas.org/mergingdata.html>? Do they work? If yes, inspect >> >> your data, does it have the same format? >> >> Looks like you chose to ignore the hard part. >> >> >> > 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/sarantis/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 >> >> >> > any idea why ? >> >> >> >> My crystal ball says that either points or polys is empty ;) >> > >> > is not empty and yes i have two shapefiles from qgis. >> >> Can I download those files somewhere? >> >> > what is the error ? >> >> No idea. Without those files I cannot run your code. > > https://www.dropbox.com/s/2693nfi248z0y9q/files.zip?dl=0 with the > shapefiles
It looks like there are no intersections in your data. With the proviso that I've learned about the library only today I think you should get an empty result set rather than the ValueError. Here's a way to reproduce the error (?) with the data provided in the project: import geopandas from geopandas import gpd world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities')) countries = world[['geometry', 'name']] def find(items, name): # didn't find the idomatic way quickly, so for index, n in enumerate(items["name"]): if n == name: return items[index:index+1] raise ValueError berlin = find(cities, "Berlin") paris = find(cities, "Paris") germany = find(countries, "Germany") print(gpd.sjoin(berlin, germany)) print(gpd.sjoin(paris, germany)) # ValueError $ python demo.py geometry name_left index_right \ 175 POINT (13.39960276470055 52.52376452225116) Berlin 41 name_right 175 Germany [1 rows x 4 columns] Traceback (most recent call last): File "demo.py", line 20, in <module> print(gpd.sjoin(paris, germany)) # ValueError File "/home/peter/virt/geopandas/lib/python3.4/site- packages/geopandas/tools/sjoin.py", line 57, in sjoin r_idx = np.concatenate(idxmatch.values) ValueError: need at least one array to concatenate $ I suggest that you file a bug report. -- https://mail.python.org/mailman/listinfo/python-list