thanks for the hint, I've not done much with PostGIS for a while!
your example data seems to have rows repeated for each station, which doesn't appear in your description so my version below aggregates over these:
WITHmonthlyAS(SELECTc.ogc_fid,date_trunc('month',m.taken)asmonth,AVG(m.value)/10AStemp_mean,MIN(m.value)/10AStemp_min,MAX(m.value)/10AStemp_maxFROMcountycJOINstationsONST_Contains(c.wkb_geometry,ST_SETSRID(ST_MakePoint(s.lat,s.long),4326))JOINmeasurementmONs.idx=m.idxWHEREc.geo_id='0500000US01003'-- running for all counties is slow, this is good for testingGROUPBY1,2)SELECTc.geo_id,c.state,c.county,c.name,m.month::DATE,round(m.temp_mean::numeric,2)ASmonth_temp_mean,MIN(m.temp_min)OVERyearASyear_min_temp,MAX(m.temp_max)OVERyearASyear_max_tempFROMcountycJOINmonthlymUSING(ogc_fid)WINDOWyearAS(PARTITIONBYc.geo_id,date_trunc('year',m.month));
I'm also rounding the mean down to a sensible number of decimal places, we certainly can't know it to ~20 significant figures!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
thanks for the hint, I've not done much with PostGIS for a while!
your example data seems to have rows repeated for each station, which doesn't appear in your description so my version below aggregates over these:
I'm also rounding the mean down to a sensible number of decimal places, we certainly can't know it to ~20 significant figures!