Link to home
Start Free TrialLog in
Avatar of jbpeake
jbpeake

asked on

Interpolated Values for Table of Evenly Spaced Points

Dear Exchange,
I am using Postgresql 8.4 with PostGIS 1.4 along with PHP 5.3.
I have two tables: one is a table of evenly spaced x,y points (grid_table)  in a square configuration and a second table (values_table) of random (scatter) x,y points within the same square area however this table has values associated with each point.  I want to assign a value from the values table to each point in the grid table within a specific radius.  I have the following code that seems to work nicely.  However I would really like to take the average of the points in a specific radius and assign that value to the grid point. Any ideas.  Secondly, I would really like to do a Inverse Distance Weighting type of function to assign the values to each grid point.  I know this would be much harder but I would appreciate any ideas.  

$query = "UPDATE grid_table SET values = values_table.values FROM values_table
WHERE ST_DWithin(values_table.the_geom, grid_table.the_geom, 0.000005)";
$query_result = pg_exec($dbconn, $query) or die(pg_errormessage());
Avatar of mahome
mahome
Flag of Germany image

the average of the point you get with ST_Centroid (http://postgis.refractions.net/documentation/manual-1.4/ST_Centroid.html).
If you have the geoms in several rows, you also need st_union before: st_centroid(st_union(the_geom))
Avatar of jbpeake
jbpeake

ASKER

Thanks for the response but I think I did a poor job of explaining:  I need to take the average of the values from each of the points that fall within the radius.  Each x, y point has a value like 3.43, 3.67, 3.55 etc associated with it.  So I need to find all the points within a radius of my grid point and get the average numeric value for that point.  I think ST_Centroid would only return the geometric center of a geometry.
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbpeake

ASKER

thanks.