0

I'm trying to add two rasters created using the rioxarray package. Both have the same xy resolution/grid (3905y, 13566x), but when added together suddenly the grid structure changes (1629y, 6799x). How to add two rioxarray rasters while keeping the same grid? I think it may have something to do with NaN values, but not sure.

enter image description here

CrossLord
  • 574
  • 4
  • 20
  • [please don't post images of code or data](https://meta.stackoverflow.com/q/285551) - they aren't searchable or readable by screen readers. Instead, please copy the terminal output into the question as a code block. thanks! – Michael Delgado Oct 16 '21 at 05:23

1 Answers1

0

this looks like a case of slightly mismatched coordinates. you can test whether your coordinates are exactly identical with xr.align(POP_roi, wasteDay, join='exact').

Assuming they're not lined up, you can address this by rounding the coordinates, e.g. with

POP_roi['x'] = np.round(POP_roi['x'], 6)
POP_roi['y'] = np.round(POP_roi['y'], 6)
wasteDay['x'] = np.round(wasteDay['x'], 6)
wasteDay['y'] = np.round(wasteDay['y'], 6)
Michael Delgado
  • 13,789
  • 3
  • 29
  • 54