4

I have a few raster datasets and I created a fishnet (polygon). I tried to add the values which the rasters have in the grid cells to the attribute Table from the polygon.

  • Can you give us some idea of what the rasters are and how you want to assign the values to your fishnet? A polygon potentially can contain many cell values, are you after the most popular value, average value, minimum, maximum etc.. do you have docs.qgis.org/2.2/en/docs/user_manual/plugins/… ? – Michael Stimson Nov 21 '17 at 23:08
  • hey thx for your answer... i have a surface elevation raster and a groundwater head raster. They both have a field with float values of their hight like 311.21. I need to get this values into the attribute table of an fishnet (polygon). All datasets have the same extend and cell size of 50x50 m. – till Kadabra Nov 21 '17 at 23:38
  • and in the second case i have an polygon file with some attributes i also want to join the fishnet table. The polygon hasent the same geometry as the fishnet. – till Kadabra Nov 21 '17 at 23:40
  • Joining, spatially, your rasters to your polygons is achieved by Zonal Statistics but you wont get all the attributes in the raster, just a statistic of them. To spatially join polygons to polygons you can use an overlay gis.stackexchange.com/questions/179602/… but that will change the geometry of your fishnet. – Michael Stimson Nov 21 '17 at 23:50
4

With QGIS one possible workaround is as follows. First, I created a polygon fishnet from raster layer for the following image (50 % of transparency for visualization purpose):

enter image description here

Afterward, with the Polygon centroids Processing tool, I created a centroids layer corresponding to the fishnet; as can be observed in following image.

enter image description here

Next I used the v.sample Processing tool for sampling raster values corresponding to centroids for each feature of fishnet. Sampled raster values can be observed in the Attributes Table of following image for Sampled memory layer produced.

enter image description here

After creating an id field in the Sampled layer, I used a Spatial join to the fishnet layer, using id as join and target field. Finally, fishnet is saved with another name and unnecessary fields (different to raster values) were deleted; as it can be observed at following image:

enter image description here

  • This is a great answer. If others are looking for something like this, I would also recommend checking out the "Point Sampling Tool" plugin. I found it very fast and straightforward to use for extracting data from multiple rasters, while v.sample was awkward. – EcologyTom Oct 3 '18 at 10:59

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.