Skip to main content
Question

How do I get the raster cell(s) with the maximum value?

  • January 26, 2017
  • 6 replies
  • 167 views

arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14

A very simple question, hopefully with a simple answer.

I have a single-band raster file with flood depths, and want to put a point or label at the deepest point ("X marks the spot"). I can get the deepest value using the RasterBandMinMaxExtractor, but how do I get the location of the deepest value.

The solution I've come up with so far is using a RasterCellCoercer converting the entire raster into a point feature class, and then extract the deepest point using a Tester transformer. But this feels to be a bit of a roundabout way, having to vectorise the raster first.

Hopefully/Surely there is a shortcut....?

6 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 26, 2017

I have two thoughts, no idea which will end up being more efficient.

1. RasterExpressionEvaluator, deepest value = 1, everything else = NoData, followed by a RasterCellCoercer with extract NoData set to No.

 

 

2. Convert the raster to a point cloud (PointCloudCombiner) followed by a PointCloudFilter, and optionally a PointCloudCoercer.

 

 

The point cloud tools are quite efficient and there are often gains in converting a raster to a point cloud and processing.

erik_jan
Contributor
Forum|alt.badge.img+19
  • Contributor
  • January 26, 2017

As a follow-up on @jdh I would add:

If you create a point cloud you could use the PointcloudStatisticsCalcultator transformer to get the values.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 26, 2017
erik_jan wrote:

As a follow-up on @jdh I would add:

If you create a point cloud you could use the PointcloudStatisticsCalcultator transformer to get the values.

Yes, that is generally more efficient than the RasterBandMinMaxExtractor

 

 


arnold_bijlsma
Enthusiast
Forum|alt.badge.img+14
  • Author
  • Enthusiast
  • January 27, 2017
jdh wrote:

I have two thoughts, no idea which will end up being more efficient.

1. RasterExpressionEvaluator, deepest value = 1, everything else = NoData, followed by a RasterCellCoercer with extract NoData set to No.

 

 

2. Convert the raster to a point cloud (PointCloudCombiner) followed by a PointCloudFilter, and optionally a PointCloudCoercer.

 

 

The point cloud tools are quite efficient and there are often gains in converting a raster to a point cloud and processing.
We have a winner! I set up a workspace with my original solution and both your suggestions (incl. @erik_jan's suggestion below), and option 2 is by far the fastest and most efficient. I took a large 500MB Esri ASCII Grid file, and got the following results:

 

  • My original solution = duration 16 min 39.8s, peak memory 881424 kB
  • Alternative solution 1 = duration 2 min 28.1s, peak memory 122756 kB
  • Alternative solution 2 = duration 1 min 20.5s, peak memory 55836 kB
Workbench (without data) attached.

 

 

I think your comment about converting raster to a point cloud may turn out to be a valuable one!

 

 


Forum|alt.badge.img
arnold_bijlsma wrote:
We have a winner! I set up a workspace with my original solution and both your suggestions (incl. @erik_jan's suggestion below), and option 2 is by far the fastest and most efficient. I took a large 500MB Esri ASCII Grid file, and got the following results:

 

  • My original solution = duration 16 min 39.8s, peak memory 881424 kB
  • Alternative solution 1 = duration 2 min 28.1s, peak memory 122756 kB
  • Alternative solution 2 = duration 1 min 20.5s, peak memory 55836 kB
Workbench (without data) attached.

 

 

I think your comment about converting raster to a point cloud may turn out to be a valuable one!

 

 

There is another scenario where conversion to point cloud has significant performance boost, and this is when using a terrain model of some sort. With some series of point or line vertices and SurfaceDraper it can take several hours to build a large model and drape features. Converting input to pointcloud and using PointCloudOnRasterComponentSetter (using Z component) same data takes less than a minute to be brought to ground/raster level.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+48
Just saw this question (from January) and wanted to mention that this is already filed as an enhancement request with our developers. It's PR#15552. I've increased the priority and posted a link to this thread, so we can hopefully get a fix and be informed about it. Glad you have a working solution.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings