# Problem with extracting netcdf file

**URL:** <https://discuss.python.org/t/problem-with-extracting-netcdf-file/15181>\
**Category:** Python Help\
**Tags:** help\
**Created:** [April 20, 2022, 8:31am UTC](https://discuss.python.org/t/problem-with-extracting-netcdf-file/15181 "2022-04-20T08:31:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hossainhurrahaman](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hossainhurrahaman](https://discuss.python.org/u/hossainhurrahaman)\
**Post date:** [April 20, 2022, 8:31am UTC](https://discuss.python.org/t/problem-with-extracting-netcdf-file/15181/1 "2022-04-20T08:31:04Z")

</div>

I am relatively new to python programming.i have downloaded a NetCDF file from IMD which contains Rainfall data. i want to extract the rainfall data for a particular coordinate … when i print it it shows dash line and mask (true and false value) it also shows fill value -999.0… how can see the rainfall values … need your help

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/a/a910c97db0753fa0f4d5292feb28c6a688545e6f.png)

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [April 25, 2022, 3:51am UTC](https://discuss.python.org/t/problem-with-extracting-netcdf-file/15181/2 "2022-04-25T03:51:12Z")

</div>

Welcome!

Please don’t post screenshots of your code.

> <https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question/285557#285557>

Instead, place your code and output in code blocks, like this:

````markdown
```python
YOUR CODE HERE
```

````

(Or use the \</\> button on the toolbar)

In any case, `rain` is a netCDF variable, because you directly assigned such to the name. By contrast, with `lat` which you also printed, you first made a copy of it to a Numpy array (with `[:]`). When you print `rain`, it is only printing a truncated subset of the full data for that variable (note the `...`s) which are at the edges of the full array, which are masked out (`mask=True`) and likely outside of the boundaries of the domain (otherwise, it would print a massive chunk of text to your console).

To explore your `RAINFALL` data, you can convert it to a Numpy array first, i.e.

```python
rain = data.variables['RAINFALL'][:]

```

then, you should be able to browse the full array interactively in Spyder’s Variable Explorer (assuming it _is_ an array).

To achieve what you’re specifically looking for, extracting rainfall data for a particular coord, you can first [get the index of the lat and lon values closest to your desired coordinates](https://stackoverflow.com/questions/33789379/netcdf-and-python-finding-the-closest-lon-lat-index-given-actual-lon-lat-values), assuming you don’t already know it is in the data, and then just call something like `data.variables['RAINFALL'][lon_idx, lat_idx]` to get it.
