0

I’m trying to write a PostGIS function that takes:

  • a geographic coordinate (based on, say, EPSG:3785)
  • a density (in points per square meter)

and returns an arbitrary number of points, close to the given coordinate, with a hexagonal distribution at the given density:

enter image description here

But here’s the tricky part: I want it to be deterministic. In other words, I want the collection of points to always be in the same place for a given density, no matter what the given coordinate is. The returned points don't need to contain the given coordinate, but they should be close to it.

For example, if I first generate some points around A, and later generate points around B, I want to make sure that all the points would be "aligned" at the same density if I later filled in all of the points between A and B:

enter image description here

I know this is possible on a 2D plane, but is this even possible on a sphere like our planet? If not, is there a way do something close? The key for my application is determinism - the distribution doesn't need to be a "perfect" hexagon, if that makes things easier.

Can anyone give me some guidance? I’ve read this post about creating hex bins over a given area, but it’s not deterministic.

seymore_strongboy
  • 934
  • 10
  • 16
  • Do A or B need to be in the center of a hexagon? (they cannot both be!) – wildplasser Feb 08 '20 at 15:34
  • Nope, neither need to be! A and B are only for proximity. – seymore_strongboy Feb 08 '20 at 16:10
  • 1
    So you could work with a *fixed* hexagonal grid. A and B only need to select the closest cells from this grid. (which should be deterministic) – wildplasser Feb 08 '20 at 16:16
  • I would seriously doubt you will get a deterministic function. The problem being to do so you need a static table. Suppose you execute your function for point A, I subsequently load a data doubling (or more) the number of points. If you now run for point A again, you are likely to get a different answer. And that's over the same point much less a different one. But Good Luck. – Belayer Feb 08 '20 at 19:06
  • I believe @wildplasser solution is the quite doable. By generating a fixed grid with equally sized cells you'd only need to place the points A and B to to the grid and get the cells around it. Of course, it assumes that points A and B do not necessarily need to be the centroid of the hexagons in the first place ;) – Jim Jones Feb 09 '20 at 10:28

0 Answers0