Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count Unique Points in Polygons seems to fail inside a loop (PyQGIS) #24528

Closed
qgib opened this issue May 26, 2017 · 6 comments
Closed

Count Unique Points in Polygons seems to fail inside a loop (PyQGIS) #24528

qgib opened this issue May 26, 2017 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@qgib
Copy link
Contributor

qgib commented May 26, 2017

Author Name: Diego García Díaz (Diego García Díaz)
Original Redmine Issue: 16628
Affected QGIS version: 2.18.8
Redmine category:processing/qgis


Hi,

I have been using the tool 'is:countuniquepointsinpolygon' inside a loop with 4000 polygons and a shapefile with 500000 points. The tool runs without any issue, but when I look at the result field, the maximum value that it gets is 2 (which is incorrect). If I run the tool from the toolbox, just for one polygon I get correct results, but for one reason inside the loop never go over 2 (maybe something with memory available?). Besides, this happens with a huge number of points, if I run the loop with a smaller shapefile point, it throws correct results.

I have uploaded to my Dropbox 5 polygons and a 10% of the points (I also get wrong values with this small sub dataset): https://www.dropbox.com/sh/f5982yd8dovsng3/AAAfwVmbtGc4uSOhi96GLHP4a?dl=0

And the script that I wrote is this:

------Code------

import os, processing

  1. Set local variables
    path = r'my\base\path\Dissolves'
    continents = r'\somepath\points.shp'
    outpath = r'path\to\outfile'

  2. Creamos la lista de shapes
    shpList = [os.path.join(path, i) for i in os.listdir(path) if i.endswith('.shp') and not 'point' in i]
    print('creada lista de', len(shpList), 'shapes')

for shp in shpList:

outShp = os.path.join(outpath, os.path.split(shp)[1])
print('Haciendo especie:', os.path.split(shp)[1])

try:

    # Ejecutamos el join espacial dentro de un tr por si hubiera algun error poder continuar al siguiente shape
    processing.runalg('qgis:countuniquepointsinpolygon', shp, continents, 'issed',  'NUMPOINTS', outShp)

except Exception as e:

    print('Error', e, os.path.split(shp)[1])
    continue

-----End Code-------

Thanks for your help!

Best regards,
Diego Garcia Diaz

@qgib
Copy link
Contributor Author

qgib commented May 26, 2017

Author Name: Giovanni Manghi (@gioman)


  • project_id was changed from 18 to 17
  • easy_fix was configured as 0
  • regression was configured as 0
  • crashes_corrupts_data was configured as 0
  • version was configured as 2.18.8
  • category_id was changed from Any to Python plugins

@qgib
Copy link
Contributor Author

qgib commented May 30, 2017

Author Name: evangelos vafeiadis (@vagvaf)


try:

    # Ejecutamos el join espacial dentro de un tr por si hubiera algun error poder continuar al siguiente shape
    processing.runalg('qgis:countuniquepointsinpolygon', shp, continents, 'issed',  'NUMPOINTS', outShp)

Hello Giovanni,

your input parameters seem to be wrong. It's 'isseed' instead of 'issed'. Could you try again?

@qgib
Copy link
Contributor Author

qgib commented May 30, 2017

Author Name: evangelos vafeiadis (@vagvaf)


PS. Can you assign the bug to me? I plan to a bit of extra code to catch an error like this.

@qgib
Copy link
Contributor Author

qgib commented Jan 4, 2018

Author Name: Borys Jurgiel (@borysiasty)


I'm updating the category. Unfortunately I have no idea how to assign it to you. Giovanni, are you around?


  • category_id was changed from Python plugins to Processing/QGIS

@qgib
Copy link
Contributor Author

qgib commented Feb 2, 2018

Author Name: Alexander Bruy (@alexbruy)


Please check with latest 2.18 and master.


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented May 16, 2018

Author Name: Alexander Bruy (@alexbruy)


Closed for the lack of feedback. Please reopen if necessary.


  • status_id was changed from Feedback to Closed

@qgib qgib closed this as completed May 16, 2018
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

No branches or pull requests

1 participant