Re: Clipping a raster (grib2), end up with zeros on left edge when cropping with mask
Shane Mill - NOAA Affiliate
toggle quoted messageShow quoted text
As always, thanks for the feedback. So to follow up, it turns out that I had to add "filled=False". In my particular situation, the user drags a bounding box over the original raster and is returned with the subsetted raster. With 'filled=False' in out_image, out_transform = mask(src, geoms, filled=False, crop=True), i get the desired result.
It looks like your feature geometries extend beyond the extent of your raster, yes? In that case, crop can create an extra row or column of pixels, which will be empty. This seems like a bug to me, or undefined behavior, at least. I suggest passing crop=False in your situation.
On Thu, May 23, 2019 at 8:52 AM Shane Mill - NOAA Affiliate via Groups.Io <firstname.lastname@example.org
I am currently clipping a grib2 file, and am ending up with zeros on the left edge of the raster. I'm not an expert with GIS so maybe this is a common problem but was curious if anyone else has experienced this before?
I think the issue is where the mask function is used with the cropping.
In the picture below, the blue edge shows the zeros.
And for context, here is the driving code that is performing the action:
Meteorological Application Developer, AceInfo Solutions
Meteorological Development Laboratory (NWS)
Join email@example.com to automatically receive all group messages.