4

I have hundreds of CSV files with geometry values in the same folder, and I'm trying to import all into QGIS, and use 'count point in grid' function to see how many of each data on each grid.

I've tried to input like 5 files, and run the count point in grid function over 5 times and get the result just fine,( run 1st file, get the return data, pass the return data in function and pass in 2nd file, get the return data....) but hundreds of them seems impractical. I've also try to create module, but still there's no such function to let me loop through a large amount of data, use the previous output and run the function again. There must be a smarter way than this.

Each of the csv file looks like this:

cookie.csv

Name Longitude Latitude
cookie 20 15
cookie 23 14

biscuit.csv

Name Longitude Latitude
biscuit 20 15
biscuit 21 14

The desired result:

Grid_ID cookie biscuit somethingElse_1 somethingElse_2
1 3 0 1 10
2 11 4 33 3

The module I tried (also for better understanding)

enter image description here

6
  • 2
    Hi, for me it sounds, as if it would be more efficient, to FIRST merge/concatanate all your CSV-files PRIOR to IMPORTING them. Subsequently you can do your analysis on a single file. With R it's a mattter of 5 lines of code and you will finde plenty of soltuions online. Maybe there's other ways to batch-concatanate CSV-files with the same column-names?
    – Vincé
    Commented Aug 20, 2021 at 6:44
  • 3
    Run Count points in polygon in batch mode: docs.qgis.org/3.16/en/docs/training_manual/processing/…
    – Babel
    Commented Aug 20, 2021 at 6:46
  • 1
    You may even run models in batch mode. Look at the bottom left of the GUI.
    – Erik
    Commented Aug 20, 2021 at 6:51
  • @Vincé Thanks for the reply. I've done merging all the data into one. But the problem is if I run the count points in polygon, it cannot distinguish how many of EACH names in polygon.
    – Cookie
    Commented Aug 20, 2021 at 8:29
  • @Babel I've tried batch mode, but I still need to add hundreds of layers one by one. Is there a way to add a folder of layer onto the current working space?
    – Cookie
    Commented Aug 20, 2021 at 8:47

1 Answer 1

2

You can run Count points in polygon in batch mode: see documentation.

In the batch dialog windon, click Autofill... and select Add All Files from a Directory… to avoid adding hundreds of layers manually.

Other options include Add Files by Pattern… where you can use the whole power of QGIS expressions to automatically select files from different folders. The documentaion of batch mode unfortunally is still based on an older version with less options.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.