Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] add polygon filter based on mean centers for GeoJsonLayer #2476

Merged
merged 4 commits into from Dec 19, 2023

Conversation

lixun910
Copy link
Collaborator

@lixun910 lixun910 commented Dec 12, 2023

This PR is to add polygon filter based on mean centers for GeoJsonLayer. Mean centers are easy to compute (much faster than computing the mass centers or geometry centers), with a downside that the mean center is more affected by the points that are far away from the center of the shape (see notes below).

mean-centers

Notes:

Mean center vs centroid (mass center):

Mean center and centroid are two different ways to represent the center of a geometric shape.
The mean center is the average of all the points in the shape. To compute it, you add up the x-coordinates of all the points and divide by the number of points, and then do the same for the y-coordinates.

The centroid (a.k.a. the center of mass, or center of gravity) of a polygon can be computed as the weighted sum of the centroids of a partition of the polygon into triangles. The centroid of a triangle is simply the average of its three vertices, i.e., it has coordinates (x1 + x2 + x3)/3 and (y1 + y2 + y3)/3. This suggests first triangulating the polygon, then forming a sum of the centroids of each triangle, weighted by the area of each triangle, the whole sum normalized by the total polygon area.

In general, the mean center and centroid will be different. The mean center is more affected by the points that are far away from the center of the shape, while the centroid is more affected by the points that have a large area.

image

Signed-off-by: Xun Li <lixun910@gmail.com>
Signed-off-by: Xun Li <lixun910@gmail.com>
Signed-off-by: Xun Li <lixun910@gmail.com>
@lixun910 lixun910 merged commit df87781 into keplergl:master Dec 19, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants