Skip to main content

Long story short I'm trying to create a Canopy height model from a set of DEM rasters and DSM rasters by subtracting the DEM from the DEM using the rastercellvaluecalculator transform. My workflow works fine except for the occasional set of DEM and DSM where they don't share the same number of pixels. This is because the DEM and DSM are generated using different sampling techniques. As such when I clip them using the clipper transform the DSM might have an extra row or column of pixels. Here is the general workflow:

Capture18 Once the DEMs and DSMs are clipped I get the raster extents for both datasets that looks like the following coming out of the sorter:

DEM

Capture20

DSM

Capture21

As you can see there is an example where the pair of DEM and DSM dont share the same number of rows (line 66). When this pair gets to the rastercellvalue calculator transform it stops on this pair, even though I have the rejected feature handling set to continue.

Capture22

I have a work around that I've tested with one image pair that just removes the extra row but I need to know which pairs don't match. I've tried using the tester, testfilter transforms but they don't check both data sets at the same time.

 

Any help or suggestions would be much appreciated.

 

I would use a FeatureMerger​ (Or FeatureJoiner) based on 'name' to get the attributes so you can test. You could rename the row and column with a prefix to make it clear. You might need to do two merges/joins so you can have both the DSM and DEM rasters. It shouldn't add too much overhead.


@virtualcitymatt​ has the right answer for this instance

 

I've just gone through a similar problem, except in this instance i was dealing with just two rasters that needed to be combined (and had considerably different coverage).

 

What I did was create a bounding box for each raster, then using the PointOnAreaOverlayer intersected them and passed into a Tester to get where they overlap. I then passed the overlap into Clippers to clip each of the incoming rasters to the common extent.

 

You could easily make this work in your case with some clever use of the GroupBy parameter, however it may be overkill for what you're trying to achieve.


@virtualcitymatt and @hkingsbury. Thanks for your help! I was able to get it to work with your advice. I've included a screenshot:

Capture23

I do however have one small issue still. My Canopy height model (CHM) that I'm writing in the last step has a problem caused by the difference in nodata values between the DEM and DSM. As such when subtracting I'm getting these large spikes in the CHM heights (I'm 99% certain the reason it's getting values of >30,000m is because its subtracting the no data value of 2^15-1 from the DSM). If I could just turn all cells with value >100m into no data value it would solve my problem. Any ideas how to do that?

Capture24


@virtualcitymatt and @hkingsbury. Thanks for your help! I was able to get it to work with your advice. I've included a screenshot:

Capture23

I do however have one small issue still. My Canopy height model (CHM) that I'm writing in the last step has a problem caused by the difference in nodata values between the DEM and DSM. As such when subtracting I'm getting these large spikes in the CHM heights (I'm 99% certain the reason it's getting values of >30,000m is because its subtracting the no data value of 2^15-1 from the DSM). If I could just turn all cells with value >100m into no data value it would solve my problem. Any ideas how to do that?

Capture24

You could add a RasterBandNodataSetter before each of your inputs into the RasterCalc and make sure those values are set as NoData

 

You could also use the RasterCellValueReplacer to replace values greater than 100


@virtualcitymatt and @hkingsbury. Thanks for your help! I was able to get it to work with your advice. I've included a screenshot:

Capture23

I do however have one small issue still. My Canopy height model (CHM) that I'm writing in the last step has a problem caused by the difference in nodata values between the DEM and DSM. As such when subtracting I'm getting these large spikes in the CHM heights (I'm 99% certain the reason it's getting values of >30,000m is because its subtracting the no data value of 2^15-1 from the DSM). If I could just turn all cells with value >100m into no data value it would solve my problem. Any ideas how to do that?

Capture24

You should look into the RasterExpressionEvaluator. You can use this to set values on bands based on conditions. Here's a few examples. You can set a value of something unique like -999 and then set that to be NoData wit the RasterNoDataSetter.


Reply