I have an array (M x N) of air pressure data (gridded model data). There's also two arrays (also M x N) for latitudes and longitudes. To build a GeoJSON of isobars (surfaces of equal pressure) I need to find clusters of pressure values with given step (1 Pa, 0.5 Pa). In general I was thinking to solve it like that:
- Build a list of objects: [{ lat, lon, pressure },..] to keep lat and lon data linked to a pressure;
- Sort objects by pressure;
- For each object in list: compare its pressure value and move to a dedicated list;
- Create GeoJSON features.
But step 3 is not yet clear to me: how to find clusters in a smart way? Which algorithm should I look for? Can I do that with scipy.cluster package?
isobar_bucket_no = trunc(pressure / 0.5), where0.5is your grid step. You don't even need sorting. If you need to calculate the range dynamically, find min and max pressure, then find an appropriate grid step so that the number of isobars is reasonable.