Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating Point Density using Python

Tags:

python

I have a list of X and Y coordinates from geodata of a specific part of the world. I want to assign each coordinate, a weight, based upon where it lies in the graph.

For Example: If a point lies in a place where there are a lot of other nodes around it, it lies in a high density area, and therefore has a higher weight.

The most immediate method I can think of is drawing circles of unit radius around each point and then calculating if the other points lie within in and then using a function, assign a weight to that point. But this seems primitive.

I've looked at pySAL and NetworkX but it looks like they work with graphs. I don't have any edges in the graph, just nodes.

like image 461
Udit Agarwal Avatar asked Dec 28 '12 13:12

Udit Agarwal


People also ask

How do you find the density of a point?

Make one O(N) pass through the data set, and compute the Haversine distance between your target point and every other point. If the other point is within distance R to your target, then add it to a result list. Then compute the density as the number of points within the circle defined by the radius.

What is the density of points?

The Point Density tool calculates the density of point features around each output raster cell. Conceptually, a neighborhood is defined around each raster cell center, and the number of points that fall within the neighborhood is totaled and divided by the area of the neighborhood.

What is Kernel Density spatial analysis?

Kernel Density calculates the density of point features around each output raster cell. Conceptually, a smoothly curved surface is fitted over each point.


1 Answers

A standard solution would be using KDE (Kernel Density Estimation).
Search on web: "KDE Estimation" you will find enormous links. in Google type: KDE Estimation ext:pdf
Also, Scipy has KDE, follow this http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.gaussian_kde.html. There is working example codes there ;)

like image 58
Developer Avatar answered Sep 25 '22 17:09

Developer