Saturday 6 April 2019

point - How to interpolate missing data from neighbours in PostGIS?


I have a dataset with point data within a given country. Let's say my dataset looks somewhat like this:


tree_id | species | age | geom
------------------------------
0 | Ash | null| ...
1 | Beech | 70 | ...

2 | Ash | 10 | ...
3 | Beech | 70 | ...
4 | Beech | null| ...
5 | Beech | 60 | ...
... | ... | ... | ...

As you can see the dataset has some missing data. For instance, tree_id 0 has no age. Therefore I would like to interpolate those missing values from a 100 meter radius.


I am looking for the mean of the species. The result should also include the number of sample trees used. A result table could then look like this:


tree_id | age_avg | samples
---------------------------

0 | 11.8 | 113
3 | 12.2 | 97
5 | 50.7 | 272
... | ... | ...

Could you get me started with some PostgreSQL query code, please?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...