CartoDB / observatory-extension

BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Account for "universal fill" when inputting best geometry characteristics #272

Closed talos closed 7 years ago

talos commented 7 years ago

Right now, sparse input geometries or points can really screw up our automatic boundary selection.

For example, twenty points across Brooklyn will choose us.census.tiger.place, as there are about twenty of them within the raster pixel around NYC. Unfortunately, NYC proper is a single us.census.tiger.place, so the points all get the same value.

A similar result could be had with a bunch of scattered small geometries, which is a common scenario for POI placement amongst other things.

What we should be doing (likely on the client side) is determining how many geometries there would be with a "universal fill", in other words:

(st_area(st_extent(the_geom)) / sum(st_area(the_geom)) * count(the_geom)

Instead of just count(the_geom), which is what we send up right now.

If there was a perfectly even distribution, say 1000 tracts across 10 sq km of 0.01 sq km each, we would get:

(10 / (1000 * 0.01)) * 1000 = 1000

However, if we had a selection of ten tracts (1%) across the same area, assuming even-sized tracts, we'd get:

(10 / (10 * 0.01)) * 10 = 1000

@makella This could be tweaked a little bit to handle points correctly, if assume a small area for them.

oriolbx commented 7 years ago

The partner from this SupportBee ticket is being affected by this issue. Account: afl-admin SB/11704219

talos commented 7 years ago

Unfortunately, the solution above is not going to get us consistently much better results.

I'm inclined to tell the partner that the best solution right now is to use the API instead of the interface, and that when the updated interface is released they will be able to select the appropriate boundary that they have uploaded.

talos commented 7 years ago

This has been fixed in observatory-extension, but still waiting for deployment in Camshaft (https://github.com/CartoDB/camshaft/pull/272) for it to be available in the UI.