I have state wide data here that I would like to overlay a grid layer of 1kmx 1km onto. I used the processing toolbox in QGIS 3 (Create Grid) in order to create a grid layer of 1km x 1km lines under the Vector Creation category. After this, I imported the fmod data and changed the symbology so that unique values are mapped to the different colors in the layer. I tried to use the Zonal Statistics tool under the processing toolbox to gather a majority (mode) statistic on each grid cell by using the following settings:

  1. Raster Layer: modified fmod layer
  2. Raster band: band 1
  3. Vector Layer containing zones: a gpkg layer I made via the previously mentioned Create Grid processing tool.
  4. Output Column Prefix: _ (default)
  5. Statistics to calculate: Majority(mode)

However, I believe (looking at the log) the tool only calculates some aggregate stat that is not what I intended on. I'm not very sure how to go about this in QGIS 3 -- currently downloading QGIS 2, but could anyone tell me what I am doing wrong?

I would like to have a grid layer where each cell in the grid contains a value determined by majority vote from the data in another layer (specifically the fmod data I am using from the link above).

  • What kind of data is the "state wide data"? Is it vector or raster? If it's a vector, is it points, lines or polygons?
    – csk
    Aug 7, 2018 at 20:00
  • I believe it's raster data. Link to the data itself is provided in the description. It is an adf file - I import it as a raster file.
    – shotes
    Aug 7, 2018 at 22:05

2 Answers 2


It sounds to me like you want the Spatial join tool found in: Analysis Tools>Overlay>Spatial Join.

It will take your 1km x 1km grid as the target feature and a point shapefile as the join features.

I believe the default merge rule for the Spatial Join tool is first, so to change it you'll need to add a new column, Type:Double, Merge Rule:Mean. The new column will be empty but it will change the merge rule for all double's to mean rather than first.

Edit: I believe you'll want to change your Match Option to 'completely contains', but you can play around with it.

To turn your raster into a point polygon use the Raster to Point tool found in: Conversion Tools>From Raster> Raster to Point.

I hope this helps.

  • Hi Daniel, I can't seem to find these tools (Spatial Join, and Raster to Point) in QGIS2 / 3. Would greatly appreciate it if you could point me to documentation for this - I'd like to merge using mode (majority win) because the different colors encode different categories.
    – shotes
    Aug 7, 2018 at 22:04
  • My mistake shotes, I thought you were working in arcmap not QGIS. these two links should help show you how to do the steps I described in QGIS. slideshare.net/shencoop/qgis-raster-to-point and qgistutorials.com/en/docs/points_in_polygon.html . In the second link he just wants a count of the points inside the polygon so he uses points in polygon. You want the mean so use the weighed version, details here - docs.qgis.org/2.18/en/docs/user_manual/processing_algs/qgis/… . If you cannot find the ability to do that with the tool use python Aug 8, 2018 at 13:44

I don't see any issue with your workflow. Just be sure that you create a polygon grid and not a line grid. When running the tool it will add an attribute table field '_majority' to the attribute table containing the mode of the raster cell covered by the grid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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