I have a huge dataset (millions of points) and a irregular grid (quadtree) in shapefile format and I need to convert the points in countes over the grid provided. I managed to make it work, using shapely Polygon.contains and a naive double-loop that scales as O(n**2).
Obviously, the script is very slow. It takes already very long on thousands of points. Is there any other way to greatly reduce running time, without writing a lot more code?
What's the typical procedure to convert so many points to a grid system, and how is it called, so that I can search further information about it?