I have a shapefile with several regions. It contains basic info like ID, Code, Name1, Name2, etc.
It is overlaid with a shapefile of points (nearly 200k). Each point represents an event with a type and a day (YYYYMMDD). The table for the point layer looks like:
ID DAY STAT1 STAT2 STAT3 ....
01 20010901 23.45 53.12 12.34 ....
02 20010901 43.35 13.56 31.84 ....
03 20010902 35.01 21.61 11.47 ....
What I would like to do is:
- Iterate through the point data for each day (one day may have one or several rows).
- For each day, count the points in each polygon region.
- Update the polygon table with a new column for that day with the point count as its value.
Ideally then, the final result would be a polygon feature with a table that resembles:
ID Code Name1 Name2 01 02 03 04 ... 198721
01 abc ABC A01 14 2 86 12 ... 27
02 xyz XYZ XZ7 66 47 23 88 ... 19
I'm using QGIS and believe this can be done w/ Python but I am not sure a) exactly how b) if another method might be more ideal.
Any help, pointers, or suggestions are greatly appreciated!
polygon_id,day,value. Which brings the suggestion of moving your data to a true geodatabase, e.g. SpatiaLite. With that your question is just a matter of the right SQL query. – steko Dec 18 '12 at 19:34