Solved

Find position and value of highest elevation on a DEM raster?

  • 6 September 2019
  • 14 replies
  • 97 views

Badge +14
  • Contributor
  • 120 replies

I am trying to find the elevation of the most prominent "peaks" in an area, but am stuck.

 

 

I have used a number of polygons to Clip a selection of mountains. These are in a raster DEM format. Now I want to find the highest point on each mountain, along with it's position. This will later be saved as a point feature.

 

 

Using the RasterCellCoercer results in an insane amount of data. I have tried to filter out the highest values before I proceed, but have not yet figured out how to do so.

 

 

The RasterBandMinMaxExtractor with a ListExploder gives me the highest value for each raster area, but I also need the position of this pixel.

 

 

Any suggestions on how to proceed? How can I get both the highest value, and it's location , without turning my computer into a toaster?
icon

Best answer by david_r 6 September 2019, 13:39

View original

14 replies

Userlevel 4

This should be much quicker than coercing into points or polygons:

The point geometry on the right side will be a 3D point giving the location of the maximum Z value. The Z value itself is also available in the attribute z.max.

Just be aware that you may have several points output for the same raster if there are several raster cells with the identical, maximum value. In that case you could use a Sampler (first 1) with a group by on the raster name.

Badge +16

This should be much quicker than coercing into points or polygons:

The point geometry on the right side will be a 3D point giving the location of the maximum Z value. The Z value itself is also available in the attribute z.max.

Just be aware that you may have several points output for the same raster if there are several raster cells with the identical, maximum value. In that case you could use a Sampler (first 1) with a group by on the raster name.

Ha the good old raster to pointcloud trick, I keep forgetting that! nice one @david_r

Userlevel 4

Ha the good old raster to pointcloud trick, I keep forgetting that! nice one @david_r

Probably the first time I've used it, so let's hope it works! :-)

Badge +16

Probably the first time I've used it, so let's hope it works! :-)

Tested it and it does!

Userlevel 1
Badge +10

Another option is to use a RasterStatisticsCalculator to calculate the Max, an expression evaluator to set a dummy value to every pixel that doesn't match the max, then use this to set as no data and use the raster to polygon to converter whilst ignoring no data values

Userlevel 4

Another option is to use a RasterStatisticsCalculator to calculate the Max, an expression evaluator to set a dummy value to every pixel that doesn't match the max, then use this to set as no data and use the raster to polygon to converter whilst ignoring no data values

Very creative! I'd love to see how it compares with the point cloud solution, performance wise.

Userlevel 1
Badge +10

Very creative! I'd love to see how it compares with the point cloud solution, performance wise.

2.9 secs (raster solution) v 3.2(point cloud solution) for my very limited sample

Badge +14

Thanks @david_r and @egomm for promising solutions! Have a nice weekend!

Userlevel 4
Badge +25

There is an existing enhancement request to return position along with z max in the RasterBandMinMaxExtractor. I'll add a note that there is a useful case here too. For your interest, the reference number is FMEENGINE-36899, in case you need to get in touch with us about it.

Badge +14

This should be much quicker than coercing into points or polygons:

The point geometry on the right side will be a 3D point giving the location of the maximum Z value. The Z value itself is also available in the attribute z.max.

Just be aware that you may have several points output for the same raster if there are several raster cells with the identical, maximum value. In that case you could use a Sampler (first 1) with a group by on the raster name.

Thanks! This worked perfect. And it was quick to!

Badge +16

Very creative! I'd love to see how it compares with the point cloud solution, performance wise.

A smallish raster:

Provides different results:

My guess is that the PC handling in FME, is still superior to raster. (using FME 2018.1.1.2)

Userlevel 1
Badge +10

There is an existing enhancement request to return position along with z max in the RasterBandMinMaxExtractor. I'll add a note that there is a useful case here too. For your interest, the reference number is FMEENGINE-36899, in case you need to get in touch with us about it.

In my test example, the RasterBandMinMaxExtractor returns a string which then can't be used in the RasterExpressionEvaluator. I wouldn't expect a max to be returned as a string?

Userlevel 4
Badge +25

In my test example, the RasterBandMinMaxExtractor returns a string which then can't be used in the RasterExpressionEvaluator. I wouldn't expect a max to be returned as a string?

Yes, it does appear to be a string attribute. But that doesn't and shouldn't stop it working in the RasterExpressionEvaluator (or any arithmetic editor). At least it seems to work for me. I can use @Value(A:_band{0}.min)+5 as the expression without problem. Does it cause an error or rejected feature for you?

Userlevel 1
Badge +10

Yes, it does appear to be a string attribute. But that doesn't and shouldn't stop it working in the RasterExpressionEvaluator (or any arithmetic editor). At least it seems to work for me. I can use @Value(A:_band{0}.min)+5 as the expression without problem. Does it cause an error or rejected feature for you?

It doesn't cause an error as such, i think it's down to the way the number is stored.

Using the following expression

if (A[0]>=@Value(A:max),@Value(A:max),-9999)

If the max value comes from the RasterStatisticsCalculator - in my case this is a Real32 value - a single pixel retains it's value and every other pixel is set to -9999.

If the max value comes from the RasterBandMinMaxExtractor as a string, the first condition is not met and every pixel is set to -9999

Reply