# Convert product to an array

**URL:** https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260
**Category:** Uncategorized
**Tags:** sentinel-5p, python
**Created:** [January 26, 2021, 12:27pm UTC](https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260 "2021-01-26T12:27:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![SebastianCon](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sebastiancon/32/117_2.png) [@SebastianCon](https://forum.atmospherictoolbox.org/u/SebastianCon)
#### Post date: [January 26, 2021, 12:27pm UTC](https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260/1 "2021-01-26T12:27:25Z")

</div>

Hello.

I am doing my final master’s thesis, here are the problems I am encountering.

- After downloading the sentienel-5P satellite, with this code:

api = SentinelAPI(‘XXXXX’, ‘XXXXX’, ‘[https://s5phub.copernicus.eu/dhus](https://s5phub.copernicus.eu/dhus)’)  
map = geojson\_to\_wkt(read\_geojson(‘spainspain.geojson’))

products = api.query(map,  
date=(date(2020, 1, 2), date(2020,8, 8)),  
producttype=‘L2\_\_NO2\_\_\_’,  
platformname=‘Sentinel-5’)

api.download\_all(products)

I manage to download the products with their metadata, I would like to be able to work with them from python i.e. select latitude,longitude, time and nitrogendioxide\_tropospheric\_column and convert it to dataframe to work.

I am trying this:  
data3 = ‘C:/Escritorio/S5P\_NRTI\_L2\_\_NO2\_\_\_\_20210118T140732\_20210118T141232\_16928\_01\_010400\_20210118T150113.nc’  
fh0 = Dataset(data3, mode=‘r’)

lat=(fh0.groups[‘PRODUCT’].variables[‘latitude’])  
log=(fh0.groups[‘PRODUCT’].variables[‘latitude’])  
time=(fh0.groups[‘PRODUCT’].variables[‘time’])  
no2=(fh0.groups[‘PRODUCT’].variables[‘nitrogendioxide\_tropospheric\_column\_precision’])

lat = lat.to\_dataframe()

error:  
AttributeError: NetCDF: Attribute not found.

In short what I am looking for is to work with sentienel data in dataframe.

Thank you very much.

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [January 26, 2021, 12:37pm UTC](https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260/2 "2021-01-26T12:37:32Z")

</div>

This forum is more focused on using the atmospheric toolbox to access S5P data (using e.g. HARP).  
Maybe another user on the forum can provide you a solution.

---

<div class="post-metadata">

### Author: ![mariliza](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@mariliza](https://forum.atmospherictoolbox.org/u/mariliza)
#### Post date: [January 27, 2021, 7:06am UTC](https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260/3 "2021-01-27T07:06:54Z")

</div>

Good morning Sebastian,

I am guessing that your  
lat=(fh0.groups[‘PRODUCT’].variables[‘latitude’])  
command has a syntax error.

I admit to be using a much more… basic function, i.e.

# reads in the TROPOMI ncdf file [=fname] from the path it is located

file = Dataset(path+fname,“r”)

# reads in the latitude and longitude arrays

lat= file[“latitude”][:]  
lon= file[“longitude”][:]

or if you wish to turn them into numpy arrays

# read in the lat/lon of the file

lat = np.array(file[“latitude”][:])  
lon = np.array(file[“longitude”][:])

I have no experience with “to\_dataframe” and cannot help with that bit, but from the error I am guessing that the reading is not performed properly, not the translation into a dataframe object.

Good luck,  
MariLiza

---

<div class="post-metadata">

### Author: ![SebastianCon](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sebastiancon/32/117_2.png) [@SebastianCon](https://forum.atmospherictoolbox.org/u/SebastianCon)
#### Post date: [January 28, 2021, 12:10pm UTC](https://forum.atmospherictoolbox.org/t/convert-product-to-an-array/260/4 "2021-01-28T12:10:21Z")

</div>

Thank you. I will try your method.
