Solved

Using vector to mask raster (VectorOnRasterOverlayer)

  • 8 March 2018
  • 3 replies
  • 14 views

Badge +5

I have a large binary raster (1 band, values either 0 or 1) that I want to mask with a polygon shapefile (which contains 1 attribute column, id, with values 0). I was thinking of using Vector on Raster Overlayer for this. However the output file is the original raster, without changes. Am I using the VectorOnRasterOverlayer correctly?

icon

Best answer by takashi 8 March 2018, 11:41

View original

3 replies

Userlevel 2
Badge +17

Hi @wolters, no, the VectorOnRasterOverlayer would not transfer any attribute value from the vector feature to the raster. It just draws the shape of the vector geometry onto RGB raster using its color value (fme_color).

I think the Clipper could help you.Send the polygon to the Clipper port, send the raster to the clipee port of a Clipper. Then check the resulting raster output from the Outside port of the Clipper transformer.It might be necessary to set Yes to the Preserve Clippee Extents parameter if the polygon was relatively large.
Badge +8

Hi @Wolters, I think it should be possible using the VectorOnRasterOverlayer, like the example that is herewith. You have to be sure however that a Z-value is present on the numeric type of raster that you are using. I suggest you use a 3D polygon with either Z=0 or Z=1. You can force your polygons 3D with the 3DForcer. However, I'm still not sure how FME handles a binary type numeric raster anyway. The example I used is a UInt8 interpretation. Please let me know if it worked for you.cuta-holeinanumericraster.fmw

Badge +5

Hi @wolters, no, the VectorOnRasterOverlayer would not transfer any attribute value from the vector feature to the raster. It just draws the shape of the vector geometry onto RGB raster using its color value (fme_color).

I think the Clipper could help you.Send the polygon to the Clipper port, send the raster to the clipee port of a Clipper. Then check the resulting raster output from the Outside port of the Clipper transformer.It might be necessary to set Yes to the Preserve Clippee Extents parameter if the polygon was relatively large.

 

I did it in a roundabout way by converting all raster values to 0 and then using the clipper on the raster, and use a combination of rasternodataremover and rastercellvaluereplacer to get the result I wanted.

 

Reply