I'm trying to create polygons from points layers. Each layer contains one point to avoid troubles due to superposition of polygons. I detailed the context here : How can I add output vector to a list to loop a geoprocessing on it?

The problem is, the solution proposed in the previous question worked well, but the context has changed a bit and now the sectors of my buffers need to be irregular but following a specific pattern, so i can't use voronoi polygons anymore.

I found a solution by customizing just a little the "create points along line" algorithm, creating hub lines to connect these points to the buffer's centroid and polygonizing.

This works great as far as the geometry is concerned, but the last step (polygonize) deletes the attributes.

I tried to set back the attributes with the spatial join algorithm, but it doesn't work : there is no error, it's just like if the algorithm did not run. Thought, it gives the expected result when used independently, outside of a script or modeler.

What am i doing wrong, and is there a solution ? Doesn't have to use the spatial join if there is a better way to do it

Here is my code :

##buffwind=output vector

import glob, os, processing


for points in glob.glob("*.shp"):
    outputs_QGISFIXEDDISTANCEBUFFER_1=processing.runalg('qgis:fixeddistancebuffer', points,1000.0,20.0,False,None)
    outputs_QGISFIXEDDISTANCEBUFFER_2=processing.runalg('qgis:fixeddistancebuffer', points,1100.0,20.0,False,None)
    outputs_SAGACONVERTPOLYGONSTOLINES_1=processing.runalg('saga:convertpolygonstolines',     outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],None)
    outputs_SAGACONVERTPOLYGONSTOLINES_2=processing.runalg('saga:convertpolygonstolines', outputs_QGISFIXEDDISTANCEBUFFER_2['OUTPUT'],None)
    outputs_SCRIPTCREATEPOINTSALONGLINESCUSTOM_1=processing.runalg('script:createpointsalonglinescustom', outputs_SAGACONVERTPOLYGONSTOLINES_2['LINES'],959.44,767.55,383.77,6524.22,None)
    outputs_QGISDISTANCETONEARESTHUB_1=processing.runalg('qgis:distancetonearesthub', outputs_SCRIPTCREATEPOINTSALONGLINESCUSTOM_1['output'],points,'ID5_35',1,0,None)
    outputs_QGISMERGEVECTORLAYERS_1=processing.runalg('qgis:mergevectorlayers', [outputs_SAGACONVERTPOLYGONSTOLINES_1['LINES'],outputs_QGISDISTANCETONEARESTHUB_1['OUTPUT']],None)
    outputs_QGISPOLYGONIZE_1=processing.runalg('qgis:polygonize', outputs_QGISMERGEVECTORLAYERS_1['OUTPUT'],False,False,None)
    outputs_QGISJOINATTRIBUTESBYLOCATION_1=processing.runalg('qgis:joinattributesbylocation',     outputs_QGISPOLYGONIZE_1['OUTPUT'],  outputs_QGISFIXEDDISTANCEBUFFER_1['OUTPUT'],['intersects'],0.0,1,'sum,mean,min,max,median',1,output_folder + "/buffwind_" + points)

output = glob.glob('*.shp')
processing.runalg("saga:mergelayers", ";".join(output), False, False, buffwind)

Finally works with the above code, i have no idea what was wrong the first time...

closed as off-topic by PolyGeo Jun 17 '16 at 20:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • For your join attributes by location algorithm, try replacing ['intersects'] with u'intersects'. – Joseph Jun 16 '16 at 9:42
  • 1
    finally works with the exact same code... i have no idea what was wrong the first time. Thanks Joseph for trying to help ! – bliblablo35 Jun 17 '16 at 10:23
  • No worries, really wonder what was wrong the first time. Hopefully it will continue to work :) – Joseph Jun 17 '16 at 10:25