I've got a dataset made up of a large range of polygons (about 70 or so) which represent structures. I also have raster layers which detail a flood depth across an area. The floods depth raster has a 10x10m cell resolution, so for most polygons (structures) there are multiple flood depth cells contained within each polygon. I'm trying to create a model which will identify the maximum flood depth value in each polygon. Now most of the cells aren't wholly contained within the polygon, but these still need to be included in the assessment, as even part of the structures will be flooded to that maximum depth.

I don't want to do this manually as there are hundreds of cells and I have over 20 scenarios to repeat the process for, so this would take days to do manually.

I feel like this should be pretty simple but i've run up short so far.

  • If you are scripting this use extract by mask, build statistics then get the maximum from there.. but that requires a spatial analyst license, do you have access to Spatial Analyst? Otherwise you could do raster to polygon an intersect (how many cells are there in the raster?) then summary statistics to get the maximum for each structure FID. Do either of those sound like a workflow you'd like to know more about? – Michael Stimson May 19 '15 at 0:06
  • Hi Michael, yes I have access to Spatial Analyst, I have tried extracting by mask, using the Polygon shapefile as the mask but this simply removes many of the raster cells, even ones which are partially or fully contained within certain polygons. I'm not sure why this is ocurring. – John May 19 '15 at 0:12
  • That is probably a separate issue, perhaps the geometries are bad (use Repair Geometry to fix), the Extract by Mask tool should extract the raster contained by each polygon (iterate over them) but I can't see if it will include partial overlap, or whether it can be made to. How big is your raster (in cells)? Perhaps your best course is to convert it to polygons then use Intersect and Summary Statistics.. that way even partial overlaps will be considered for sure. – Michael Stimson May 19 '15 at 0:23
  • The Raster is at least a few thousand cells, probably closer to 10,000. I could crop it down to a couple of thousand cells likely. Do i need to manually convert them to polygons? – John May 19 '15 at 0:27
  • Raster to Polygon, don't simplify, 10k cells isn't too bad.. adjacent cells with the same value will be dissolved. You can use Clip (data management) to reduce it to just the extent of the areas fairly quickly - this tool extracts a rectangular area, or buffer the structures by 2-3 cells (20 to 30 metres) and extract by mask to reduce the number of cells that will actually be processed into polygons, after that it's fairly quick. – Michael Stimson May 19 '15 at 0:30

This is probably a bit of a roundabout way of performing this analysis, but I just did a quick test and it worked for me:

Use the Raster to Polygon tool convert your raster, with the simplify polygons option unchecked. This should provide a polygon representation of the raster cells with the 'gridcode' attribute being the value of the raster cells.

Intersect the result of the Raster to Polygon process with the structure polygons. Set the Join Attributes to 'All'.

Dissolve the result of the Intersect process. The dissolve field should be the field which uniquely identifies each structure. Add the field which contains the flood depth values as a statistics field, with the statistics type set to 'MAX'.

The result of the Dissolve process should be a recreation of the structure polygons, with an attribute containing the maximum flood depth occurring within the polygon. You can then join that back to the original structure dataset and copy the max flood depths across via the field calculator

  • of course you could place the process I mention into a model or script tool if it's a regular task. – Adam May 19 '15 at 0:42
  • Not too roundabout, but the key problem lies in the Raster to Polygon tool, which @Tom has just discovered can only handle Integer raster inputs. That means no decimals, and rounding up or down to nearest whole number (possibly using the Int tool on it first). The only way to do it with a float is the method I outlined at the end of my answer. – Chris W May 19 '15 at 1:15
  • 2
    Or multiply and truncate the float to integer then divide the result by the same amount... values for integers can't be more than 2147483647 (maximum int32 signed) so you've got a bit of wiggle room. There is a roundabout way with an advanced license (raster to point, raster to polygon using int values then Feature to Polygon) copies the values exactly as points and then use the points to attribute the new polygons. – Michael Stimson May 19 '15 at 1:20
  • 1
    Forgot about that. Yes, you could truncate and divide, or multiply by a factor of 10 to the x and divide back by the same value when you had it in vector. – Chris W May 19 '15 at 1:22

I would do this the other way around from current comments/answer. I am assuming your scenario changes are where the flood values, not the buildings, change.

Convert your buildings to raster with Polygon to Raster, using your flood raster as the extents and matching cell size/row column count/etc. There is some risk that a resulting cell won't be classed as building even if the polygon line touches it, particularly depending on cell size and how much of the cell is contained within the polygon. At that point you can either double/quadruple the cell counts (and reduce the size, thereby increasing the resolution) and then resample it back down with a max value method or something. Basically you have to keep in mind no matter which way you go, converting between raster and vector will lose accuracy somewhere by either over or under inclusion.

Once you have your buildings as a raster, which you only have to do once, you can use the Zonal Statistics tool to get the max value in each zone (buildings). Note that you can use this tool directly with your buildings as polygons, but it does an internal conversion from vector to raster that you have no control over (so you have even less of an idea if a cell touches a building but isn't fully within, which way does that cell get counted). You could also buffer your polygons by maybe half cell size and use those as the zones. Again, you're picking which side you want to error on (inclusion or exclusion).

If you really want to be precise about it and ensure you include any raster cell that touches your building, you'll need to convert your raster to a vector grid. And because it's a float and not an int you either have to multiply the raster by some power of ten, run it through the Int tool, and then divide the value back again once converted to raster, or do it manually. Manually means creating a fishnet identical to your raster including label points, then using those points to sample the raster, then join field-ing the points to the fishnet cells to transfer the flood depth value, and then doing the intersect/dissolve approach that Adam outlines.

You'll have to make a choice between fewer steps (single tool run with zonal stats and building vectors as direct zone input) with perhaps less accuracy, or a more complicated process requiring more steps (and therefore a model/script to be easily replicable).

  • There is a significant risk on 10m cell size that portions of buildings will not be included in the raster.. to counter this buffer you buildings by half a cell size to ensure Cell Center assignment... this would work best if you set CellSize and SnapRaster environments to match the existing raster... two (good) ways to achieve the same result. – Michael Stimson May 19 '15 at 1:18

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.