Skip to main content
Tweeted twitter.com/StackGIS/status/1376096748200996864
Reduced scope to increase focus
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Clip Clipping raster layer with *raster* mask layer in QGIS

Given two input layers

  1. The clip layer - an arbitrary layer (though in my case it's a float 1 band geotiff)
  2. The mask layer - a paletted raster in which every pixel is either NO DATA or a single "color" value, same for every pixel.

I want to create an output raster whose overall extent matches the extent of the mask layer and each pixel is either NO DATA if the corresponding pixel of the mask layer is NO DATA or the value of the corresponding pixel from the clip layer if the corresponding pixel of the mask layer is not NO DATA.

I know I can mask the clip layer with a polygon, but the mask layer is a raster. Polygonizing the raster layer is possible in principle, but would result in a polygon with a lot of very short edges.

Is there a direct way to do this in QGIS? 

I suppose there's probably a path that involves creating a new layer and using the raster calculator, but I'm hoping there's something more direct. Further complicating the matter is that the two rasters might not have the same resolution and origin.

I believe this is equivalent to Extract by Mask in ArcMap.

A gdal command solution is equally acceptable to QGIS. A solution in R is OK, but not preferred.

Clip raster layer with *raster* mask layer in QGIS

Given two input layers

  1. The clip layer - an arbitrary layer (though in my case it's a float 1 band geotiff)
  2. The mask layer - a paletted raster in which every pixel is either NO DATA or a single "color" value, same for every pixel.

I want to create an output raster whose overall extent matches the extent of the mask layer and each pixel is either NO DATA if the corresponding pixel of the mask layer is NO DATA or the value of the corresponding pixel from the clip layer if the corresponding pixel of the mask layer is not NO DATA.

I know I can mask the clip layer with a polygon, but the mask layer is a raster. Polygonizing the raster layer is possible in principle, but would result in a polygon with a lot of very short edges.

Is there a direct way to do this in QGIS? I suppose there's probably a path that involves creating a new layer and using the raster calculator, but I'm hoping there's something more direct. Further complicating the matter is that the two rasters might not have the same resolution and origin.

I believe this is equivalent to Extract by Mask in ArcMap.

A gdal command solution is equally acceptable to QGIS. A solution in R is OK, but not preferred.

Clipping raster layer with *raster* mask layer in QGIS

Given two input layers

  1. The clip layer - an arbitrary layer (though in my case it's a float 1 band geotiff)
  2. The mask layer - a paletted raster in which every pixel is either NO DATA or a single "color" value, same for every pixel.

I want to create an output raster whose overall extent matches the extent of the mask layer and each pixel is either NO DATA if the corresponding pixel of the mask layer is NO DATA or the value of the corresponding pixel from the clip layer if the corresponding pixel of the mask layer is not NO DATA.

I know I can mask the clip layer with a polygon, but the mask layer is a raster. Polygonizing the raster layer is possible in principle, but would result in a polygon with a lot of very short edges.

Is there a direct way to do this in QGIS? 

I suppose there's probably a path that involves creating a new layer and using the raster calculator, but I'm hoping there's something more direct. Further complicating the matter is that the two rasters might not have the same resolution and origin.

I believe this is equivalent to Extract by Mask in ArcMap.

Source Link
Llaves
  • 6k
  • 6
  • 33
  • 58

Clip raster layer with *raster* mask layer in QGIS

Given two input layers

  1. The clip layer - an arbitrary layer (though in my case it's a float 1 band geotiff)
  2. The mask layer - a paletted raster in which every pixel is either NO DATA or a single "color" value, same for every pixel.

I want to create an output raster whose overall extent matches the extent of the mask layer and each pixel is either NO DATA if the corresponding pixel of the mask layer is NO DATA or the value of the corresponding pixel from the clip layer if the corresponding pixel of the mask layer is not NO DATA.

I know I can mask the clip layer with a polygon, but the mask layer is a raster. Polygonizing the raster layer is possible in principle, but would result in a polygon with a lot of very short edges.

Is there a direct way to do this in QGIS? I suppose there's probably a path that involves creating a new layer and using the raster calculator, but I'm hoping there's something more direct. Further complicating the matter is that the two rasters might not have the same resolution and origin.

I believe this is equivalent to Extract by Mask in ArcMap.

A gdal command solution is equally acceptable to QGIS. A solution in R is OK, but not preferred.