I have a netCDF file. After converting the file into a Raster layer, I extract it for my study area i.e Pakistan. After applying the extract by mask tool the extracted raster layer does not properly fit the shapefile on the boundary.

The problem is highlighted in the image attached. enter image description here

Can anyone please tell me what is the reason for this?

  • 2
    This is because the 'mask' is set on cells that are mostly covered by your polygon, so those that are only partly covered are omitted. Try converting to raster with snap raster and cell size of your NetCDF and use MAXIMUM_AREA cell assignment, if that doesn't work buffer your mask by most of one cell resolution. Oct 19, 2017 at 4:27
  • Use clip instead (data management) and select the option to 'maintain clipping extent'
    – jbalk
    Oct 19, 2017 at 4:49
  • Where is "snap to raster" tool located
    – ssh
    Oct 19, 2017 at 5:03
  • 1
    Snap Raster is an environment setting resources.arcgis.com/en/help/main/10.2/index.html#//…, it forces the cells to align exactly. If you're open to GDAL the GDALRasterize utility allows -at (all touched) as an option, which means any cell that is touched by a polygon at all is converted to raster, with a hybrid Esri solution of create new raster with Snap Raster, Extent and Cell Size from your NetCDF this should give you a precise mask that covers your entire polygon area. Oct 19, 2017 at 5:04
  • Try resampling your raster to smaller pixels = higher resolution and then Extract by mask or Clip
    – BERA
    Oct 19, 2017 at 5:16

3 Answers 3


You should use the clip tool from the data management toolbox.

When using the tool, select your polygon as the Output Extent.

Tick the box to Use Input Features for Clipping Geometry (this becomes available when you add the polygon in the Output Extent).

Tick the box to Maintain Clipping Extent.

This will resample the raster at the clipping boundary to match the polygon boundary and will result in a raster that covers the entire polygon.

UPDATE: Your cell size is very large. There is no way cells that big will ever match up with your polygon boundary. You will either have overlap or gaps.

To match the polygon boundary, you will need to resample the raster to smaller cell size. You're trying to fit a square peg into a round hole, if that makes sense (you have big square blocks that you are trying to fit into a curved polygon boundary - you need to make the block smaller).

enter image description here

  • I tried using Clip tool but it didn't resolve the issue.
    – ssh
    Oct 19, 2017 at 5:00
  • I think the problem is the cell size. There is no way you are going to match the shape of you boundary with cells that big.
    – jbalk
    Oct 19, 2017 at 5:58

I had same problem but I could solve that by change "Processing Extent" in Environments..., Click on Environments...

input snap raster Snap raster can be your polygon you want extract raster by that. or you can specific extent manually by choose "As Specified below"

Remember: first of all define Input raster and Input raster or feature mask data and output raster after that begin to configure environment I described here.


If you have advanced license, try converting your polygon (eg. select only Pakistan feature) to raster first by using your raster as snap raster and then retry Extract by Mask.

  • I tried but it wont work. After applying several method, I guess the problem is due to the cell size of raster. If the cell size is bigger then it would not fit the boundary of mask.
    – ssh
    Oct 19, 2017 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.