Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have two shapefiles....

  • points containing a number field 'response_time'
  • a polygon grid of square polygons containing fields including 'PNTCNT' with the number of points per polygon, calculated already using the tool 'points in polygon'

There are between 0 and 600 points within the bounds of each polygon in the grid.

I want to add fields to the polygon grid for the mean, min and max response times within each polygon, in addition to the PNTCNT field already there.

I have tried the 'Join attributes by location' tool, making the polygon layer the target and the points the join layer, and vice versa. I've selected 'take summary of interesting features'.

But I can't get the result I want. All I end up with is the polygon grid again but with an extra field 'COUNT' which replicates (or duplicates) the 'PNTCNT' field. No min, max and mean of values from the points layer.

What am I doing wrong? Is there a better way to do this? I have tried this using QGIS 1.7 and 1.8.

share|improve this question
2  
Tested using QGIS sample data with 1.8 and it seems to work. A possible source for problems are duplicate column names due to Shapefile limitations. –  underdark Feb 14 '13 at 17:12
add comment

3 Answers 3

I don't have time to try this out, but in my head it might work...if you have a unique ID for each grid square, and get that ID into a field on each point, then you should be able to get all the statistics you want by using the GroupStats QGIS plugin on the point layer, grouping by the ID. (then save that, join back to the grid and you're in business) Maybe there's something easier still...

share|improve this answer
add comment

Do you have PostGIS set up? If so, this is a pretty trivial set up an update query once you import your shapefiles.

UPDATE polylayer SET meantime = averageist, mintime = smallest
, maxtime = biggest FROM (
    SELECT y.id, avg(points.responsetime) As averagist, min(responsetime) As smallest
    , max(responsetime) as biggest
    FROM pointlayer x, polylayer y
    WHERE ST_Intersects(pointlayer.geom, polylayer.geom)
    GROUP BY y.id
) t
WHERE polylayer.id = t.id;
share|improve this answer
add comment

I feel like there is a glitch in the QGIS > Data Management Tools > Joining by location at QGIS v1.8.0; at least in my test cases of joining points to overlapping polygons, or polygons to internal points (with different CRS). I'd guess that you need to alternately export the shapes to PostGIS and perform SQL spatial queries to get the results you need in QGIS.

share|improve this answer
    
And you might look at Python for processing some of the statistics you need. –  user12711 Feb 14 '13 at 15:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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