The objective is that each point has an "evalfield" attribute associated with it. I want to be able to cluster them such that the sum of the clustered points ad up to a predetermined value that I decide.(last column).
To illustrate with an example: Here are a collection of points , with their attribute on the basis for which clustering is too occur written above them. (0.5,0.6 etc.)
So I followed the steps and pretty much copied out the code as is to run it in qgis.
import geopandas as gpd from shapely import geometry as geom gdf = gpd.read_file('filteredptlst.shp') exploded_gdf = gpd.GeoDataFrame() exploded_gdf.crs = gdf.crs print('starting ...') for index, row in gdf.iterrows(): if float(row['evalfield']) == 0.01: exploded_gdf = exploded_gdf.append(row, ignore_index=True) else: for i in range(0, int(row['evalfield']*100)): entry = row.copy() entry['evalfield'] = 0.01 exploded_gdf = exploded_gdf.append(entry, ignore_index=True) print('processing done ... saving') gdf.to_file(driver='ESRI Shapefile', filename="result.shp") print('saved')
But I keep getting this error:
Python Console Use iface to access QGIS API interface or Type help(iface) for more info execfile(u'C:/Users/USER/OneDrive/Documents/Studies etc/adrchitectural design/thesis/Thesisgisdata/Siteselectionalgs/alg1_point_filtering_explosion.py'.encode('mbcs')) Traceback (most recent call last): File "<input>", line 1, in <module> File "C:/Users/USER/OneDrive/Documents/Studies etc/adrchitectural design/thesis/Thesisgisdata/Siteselectionalgs/alg1_point_filtering_explosion.py", line 24, in <module> gdf = gpd.read_file('filteredptlst.shp') File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\geopandas\io\file.py", line 19, in read_file with fiona.open(filename, **kwargs) as f: File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\fiona\__init__.py", line 170, in open raise IOError("no such file or directory: %r" % path) IOError: no such file or directory: 'filteredptlst.shp'
Ive already tried changing the project environment and putting in a complete file path to the location of the file.
I couldn't se anything wrong with the code so I ran it separately in Visual Studio , but that doesn't seem to work either , there are no trackback errors but none of the print messages which I put I ( to check) arent't displayed either.
P.S. I'm really new to both GIS and Python and there must be something really obvious I'm overlooking here.