I have a polygon layer (~130k square polygons with some small overlaps) and I have imported a road network from OpenStreetMap (via Geofabrik, ~141k road segments) for my study area. I used the field calculator to assign a numeric category to each road type. Here is the code I used:
CASE WHEN "type" = 'motorway' OR "type" = 'motorway_link' OR "type" = 'trunk' THEN 5 WHEN "type" = 'trunk_link' OR "type" = 'primary' OR "type" = 'primary_link' OR "type" = 'secondary' THEN 4 WHEN "type" = 'secondary_link' OR "type" = 'tertiary' OR "type" = 'unclassified' THEN 3 WHEN "type" = 'tertiary_link' OR "type" = 'residential' OR "type" = 'yes' THEN 2 WHEN "type" = 'track' OR "type" = 'service' OR "type" = 'living_street' THEN 1 ELSE 0 end
This resulted in an additional column specifying the road category. Now my goal is to check in each of my polygons (sort-of grid-cells) what is the maximum road category number from that list. I removed all columns except the road category from the roads layer. Then I converted both layers to the same CRS.
Next I went to Vector -> Data Management Tools -> Join Attributes by Location... and selected the polygon layer as Target and polygon layer as Join. Chose "take summary of intersecting features" and marked "Max". Also picked "Keep all records".
The resulting layer is a polygon layer identical to the polygon layer I had before, only with added columns of MAX and COUNT, both of which are filled entirely with NULL values.
What am I doing wrong?
I'm using QGIS 2.12.3-Lyon.