I have an ASCII Esri file of the type:

ncols 5201
nrows 4001
xllcorner -65
yllcorner -35
cellsize 0.025
NODATA_value -9999
-9999 -9999 -9999 255 256 -9999 -9999 ...
-9999 -9999 -9999 -9999 -9999 -9999 -9999 ...
-9999 -9999 -9999 -9999 255 -9999 230 ...

I'm trying to import it with rioxarray by doing:

import xarray as xr
import rioxarray

da = rioxarray.open_rasterio('data.asc',masked=True)

What I get is a graph with the correct coordinates, but no data shown: enter image description here

Do you know why this is?

da is imported as an xarray.DataArray and looks like this:

enter image description here

  • Seems like it is a lot of data to plot. Can you try with da.plot.imshow()? Jan 17, 2021 at 23:25
  • I get ValueError: A 3-dimensional array was passed to imshow(), but there is no dimension that could be color. At least one dimension must be of size 3 (RGB) or 4 (RGBA), and not given as x or y. I guess because the array has also the "band" dimension.
    – gioarma
    Jan 18, 2021 at 11:35

2 Answers 2


This should do the trick:

import rioxarray

da = rioxarray.open_rasterio('data.asc', masked=True)
  • Great, thanks a lot!
    – gioarma
    Jan 19, 2021 at 9:03

Turns out the data were just too many and the xarray plot function could not handle it. By selecting a chunk of size not much smaller than the original data, the plot looks fine.

Note that by using rasterio's show function instead there is no problem plotting this amount of data:

from rasterio.plot import show

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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