I have a geopandas dataframe that contains points at arbitrary lat/lon points. I would like to create a raster dataset so that each point in the regular grid contains the number of elements of the dataframe contained in a circle of a ccertain radius. The difficulty is that this number should contain only unique numbers respect to a certain column.
bb is my dataframe,radius is the distance from the center of the cell for whihc I want the numbers.
I am currently doing this using this code:
mappa = numpy.full((nrows, ncols), 0)
for col in range(ncols):
for row in range(nrows):
lat=row*cellsize+bbox[1]
lon=col*cellsize+bbox[0]
ff=bb.cx[lon-radius:lon+radius,lat-radius:lat+radius] # those give the rows falling in the limitss
mappa[row,col]=len(ff['flkey'].unique())/period # with this i count only unique points respect to a column flkey
The dataframe bb contains a huge number of points so that the method is extremely slow.
I would like to improve performing the check only in points in which there are sufficient numbers as most of the points in the map there are no points. So I would like to generate a preliminary density map and then analyse only the lat/lon points in which the density is significant.
Is there a point density funciotn similar to the ESRI function PointDensity_sa ?
Thanks
