1

I have a bathymetric raster from which I want to extract the max depth value within a mask (vector) layer. The vector layer has 252 circular polygons The end result must have x, y and depth attributes

I tried the zonal statistics function, but this function only adds the max value and not the x and y coordinates


Base Map

I have added a screen shot of what I actually want:

I have a one raster (north sea bathymetry) containing 63 locations. (In the screenshot only a few locations are shown.) At each location a jack-up barge (which has 4 legs hitting the seabed) is positioned. The center xy coordinates of the legs are known (I have a CSV) I created a delimited layer of all these coordinates (CSV). Then I made a circular buffer around all coordinates, which represents the footprint of the legs.

Now what I want is to get the Max value (x,y depth) of the raster within each circle and store the values in a point file. This point file should have 63 x 4 =252 records.

I also need this for the Min value

1

Here is a new vector based workflow that should get you a lat/long location with the highest value within each circle.

  1. Convert your raster grid to points. There is a question here that deals with this. The answer involving SAGA is the most straight forward, in my opinion. Just make sure the output points have FID or other unique ID in the attributes table.
  2. Use a spatial join to attach a unique ID from the circles to the points from raster layer. This could be as simple as the FID, it just needs to be unique.If circle overlap, make sure the spatial join is one to many so that a point falling in two circles will show up in the output twice, once for each circle.

You now have a layer of raster cell points with unique point ID, raster values and an ID denoting what circle they were in. All you need to do now is use a pivot/crosstab table function to select from within each group of circle IDs, the point ID that corresponds to the maximum value. That shouldn't be too hard in Excel, Access, QGIS, or other SQL based DB management software. Without knowing which you are using, an exact answer is difficult. This question shows you how to run a cross tab in SQL. Access and Excel are a bit more user friendly for the novice.

This previous answer does not get you what you want. After you run zonal statistics, you can do one of two things to get the x,y. 1. Convert the output to a centroid, using the 'centroids' tool, then calculate new fields for lat and long using the $y and $x functions. 2. Calculate the centroid of the circle using the 'centroid' function in the field calculator (something like 'centroid($geometry)')

6
  • I thought the Zonal Statistics function adds the (max) value to the attributes of the masked vector layer, not the x and y? – Gerben Mar 17 '20 at 13:44
  • So after zonal statistics, the user should have a copy of the input vector layer with the desired raster value statistics included. My steps, conducted after zonal statistics, will attach an x and y coordinate to the attributes table. – Kingfisher Mar 17 '20 at 13:47
  • But isn't the X and Y, you mention, the center of each circular polygon of the vector layer, because that is what the centeroid function does (after running). The MAX value is somewhere in that circle not at the center – Gerben Mar 17 '20 at 13:58
  • Oh, I did not understand that you wanted the location of the MAX value to be represented as the coordinate. I was actually a bit confused as the the use of the output under my outlined method. – Kingfisher Mar 17 '20 at 14:10
  • In that case, vector, instead of raster, analysis might be better. I can post a suggested workflow in a few hours. – Kingfisher Mar 17 '20 at 14:13

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.