-
Notifications
You must be signed in to change notification settings - Fork 7
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
Weighted Centroid seems to be not working correctly #79
Comments
Looking in to it now thanks for the heads up @saleiva |
with that amount of points and randomly distributed '2' and '1' I think is correct. Test it with two points table |
but the centers are exactly the same, that's very weird, don't you think? |
Try it with something like: with points as (
select (s * s) as weight, st_makepoint(s,s) as the_geom from generate_series(1,2) s
)
--select st_astext(the_geom), weight
select st_astext(cdb_crankshaft.CDB_WeightedMean(the_geom, weight)) as the_geom
from points And play with the IMO it's working OK. |
@saleiva visually can be misleading (since there is snapping), did you test it matematically? |
lat/long values where the same at a quick sight 2016-06-23 12:16 GMT+02:00 javi santana notifications@github.com:
Sergio Alvarez Leiva |
@saleiva When I try it they look different . Not by much but different |
With some more tests it seams to be working . 4 points 3 on the right 1 on the left with various weightings does what you would expect it to do. I think one of the reasons your not seeing a big effect in the crimes data is the weights are essentially randomly assigned so they will tend to cancel out. If you give crimes where there was an arrest weight 200 and crimes where there wasn't a weight of 1 then the map looks like this: Where the blue points are the unweighted centroids and the orange points are the weighted centroids. So I think its working ok |
retested. Seems like yesterday we fucked up the data or something. You guys win |
FAV |
Download this dataset.
https://team.cartodb.com/u/saleiva/tables/chicago_crimes_2014
I've created two fake columns for testing (crimes_value and crimes_value_2)
The centroids you get when using crimes_value column (all rows equal to 1) as weight is the same result you get when using cromes_value_2 (lots of rows equal to 2, the rest to 1).
cc/ @javisantana @rochoa @ohasselblad @stuartlynn
The text was updated successfully, but these errors were encountered: