Repository navigation
v.ppa: Point Pattern Analysis - #3826
Conversation
|
The G and K functions are complete, but I'm still working on the functions. |
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
Restructure the tool for core inclusion and fix correctness problems found in review: - Split main.c into per-function files (g_function.c, f_function.c, k_function.c, result.c) sharing local_proto.h. - Use the computational region as the observation window for the intensity estimate, F function sampling, edge correction geometry, and default distance range. Points outside the region are ignored with a warning. - Add Ripley's isotropic edge correction for the K and L functions (correction=isotropic|none, default isotropic), using the closed form for rectangular windows. - Evaluate K and L up to max_distance (default one quarter of the shorter region side) instead of the O(n^2) pattern diameter, and estimate K with one radius query per point. - Print results to standard output by default with format=plain|csv|json; JSON output is a records array with method, point count, intensity, window, and correction metadata. The output option optionally writes to a file for all methods. - Fix correctness bugs: intensity truncated to int made the G CSR reference always zero, kdtree_knn was called with k=2 writing into scalars, duplicate coordinates were dropped from the k-d tree, omitting output crashed on fopen(NULL), and num_distances was ignored by the G and F functions. - Remove the unfinished Monte Carlo envelope code and the simulations option; simulation envelopes are planned as a follow-up (see TODO in the manual). - Add the nprocs and seed standard options; report all functions together with their theoretical values under CSR. - Replace the gunittest testsuite and committed test data with pytest tests on seeded synthetic patterns that assert agreement with CSR theory, clustering detection, and edge correction behavior. - Register the tool in vector/CMakeLists.txt and use grass/gjson.h instead of the removed grass/parson.h. - Rewrite the manual pages. The restructured estimators and the isotropic correction were implemented with AI assistance; the correction was validated numerically against a brute-force estimate of the circle fraction inside the window, and the estimators against CSR theory on seeded random patterns.
Add a pattern map figure (clustered, random, dispersed) rendered with d.vect and one plot per function comparing the three patterns against the CSR expectation. The figures are generated by the included doc_figures.py script from seeded synthetic patterns, so they are reproducible. Created with AI assistance.
@wenzeslaus see how the code is broken out now. |
|
I cross-validated v.ppa against spatstat 3.0-7 (Kest, Lest, Gest, Fest) on identical coordinates and r values: K/L agree to machine precision, G exactly, and F within the Monte Carlo noise of its random test points. Validation run with Claude Code. |
|
Maybe to expose this little bit more, consider adding it somewhere to GUI menu. Also check whether the topology needs to be built for this to run. Not sure about the CodeQL CI, looks unrelated. |
I exposed v.ppa in the Point Analysis and Vector Reports And Statistics toolboxes.
Topology is not needed for the tool to run.
Agreed |
I'm adding vector point pattern analysis functionality for F, G, L, K, and Bivariate Ripley's K.