CartoDB / crankshaft

CARTO Spatial Analysis extension for PostgreSQL
BSD 3-Clause "New" or "Revised" License
54 stars 20 forks source link

adds contiguity, conditional clustering (max p) #160

Open andy-esch opened 7 years ago

andy-esch commented 7 years ago

Description

This PR adds a new function, max-p, that analyzes a polygon dataset with numeric attributes and produces a set of contiguous regions according to properties that the user can define. For instance, it can find states which have similar per capita income, group counties into larger regions such that each formed region has approximately the same population aggregated from the counties, and so on.

Other changes

This code also contains some refactoring of the pysal_utils submodule which several of the analyses (e.g., moran, getis, markov) rely upon. For example, a utility used solely in markov has been repurposed as a pysal_utils function for getting multiple attributes and packing them into a NumPy array. The query-generating functions for where and selects continue to become more abstract as they're used in slightly different cases.

TODOs

Other tasks: