4

What I am trying to do is average a set of points with a separate boundary.

Example

Each of the larger circles is a fixed distance around a sample point (typically the area sampled) with each of the smaller points being a yield point. What I have been doing in the past is creating an averaged raster grid of yield and then using the point sampling tool to give me a yield per sample point (with attributes of the sample included).

While this is a fairly good process, it has hard edges and the points do not always end up in the center of the grid.

What I would like to do is use a similar process as the point sampling tool, but with a noticeable difference. I would like to return the aspects of the sampling attributes along with the average and standard deviation of the yield points within the boundary. I am only needing them in a csv/txt file to run them through some statistics to find relationships.

Is there a process out there someone has used to solve a similar problem?

4

I prepared a simplified example here:

enter image description here

  • sample_points: your small points which has id and yield fields (yield as seen on the picture as label: 366, 294, ...)
  • large_circles: your big orange circles. I understand it was originally points which you have displayed as buffer. (I used Geometry generator).

enter image description here

Now we can create a Virtual Layer Layer | Add Layer | Add/Edit Virtual Layer. Import these two layers (sample_points and large_circles) then,

(1) To create a table of Yields

SELECT sample_points.*, large_circles.ID AS circle
FROM sample_points
CROSS JOIN large_circles
ON st_within(sample_points.geometry, st_buffer(large_circles.geometry, 1000))=1

enter image description here Usually this table is my goal.

(2) According your post, you need average and sd.

SELECT Count(*) AS samples, 
       Avg(sample_points.yield) AS avg_yield, 
       StdDev_Samp(sample_points.yield) AS sd_yield
FROM sample_points
CROSS JOIN large_circles
ON st_within(sample_points.geometry, st_buffer(large_circles.geometry, 1000))=1
GROUP BY large_circles.id 

enter image description here

  • Just so I fully understand, when you do the second part, are you doing it in the table, or are you running a python script? – Chris C Dec 6 '17 at 16:34
  • @ChrisC It is called Virtual layer, called up from menu Layer | Add Layer | Add/Edit Virtual Layer. – Kazuhito Dec 6 '17 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.