Skip to main content

Hi,

I'm trying to clip raster data using a 1k*1k grid shapefile. I'm not achieving the desired results as the clipping is imperfect, resulting in gaps or extra pixels. My goal is to clip the raster strictly within the boundary without any additional or missing pixels.

Could someone please suggest a workflow for this?

sample data:

 

Hi @mahapandian,

I see a couple of ways to achieve this (there might be more or better ones). The problem comes from fact that the raster not aligning with your grid to the pixel before clipping. This means your goal is to snap the raster to the grid. An easy way is to simply measure the offset in Data Inspector and then using Offsetter to move the raster to the grid. This is a minimal shift, it should be smaller than a pixel, so it shouldn’t affect accuracy. This is, of course, not a perfect solution, especially if the required offset is not some easily measurable round number.
I tried another method, which works automatically and should snap the raster perfectly. I rasterized the grid first - this gave me a raster that aligns to to the grid (of course, your pixels size should allow the raster to fit into the tiles perfectly - if your tile is 10x10, you can’t fit a raster with pixel size 7 into it). Then I sent both this new raster and my original raster to RasterMosaicker, and set Snapping Type to Offset. With a couple of AttributeCreators and Sorter, I made sure my grid raster enters Mosaicker first - this will define the snapping origin, which should match the grid origin. It also allows me to hide my grid raster - I don’t need to see it in the output. This is it, then I can clip the perfectly aligned raster. See the attached workspace.

Dmitri 

 

 


Reply