how to merge two NetCDF4 files into one

Hi everyone, i am currently working on Sentinel 5P Tropomi data. the data is available in the format of NetCDF6. i am trying to merge two images into one. i need the lattitude, longitude and NO2 column data in the new merged file. is it possible to merge two files and have the merged file have all the varaiables which the two files have. if so please let me know how i can merge these two files in Matlab.

2 comentarios

KSSV
KSSV el 11 de Oct. de 2021
Yes happily it can be merged.....shared your files so that we can have a look.
Sreeraj R
Sreeraj R el 11 de Oct. de 2021
Editada: KSSV el 11 de Oct. de 2021
yes sir....sorry there is a correction the data format is not NetCDF6 but NetCDF4 (not NetCDf4_classic) . i have attched the google drive link for the data

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 11 de Oct. de 2021
file1 = 'tropomi1.nc' ;
file2 = 'tropomi2.nc' ;
x1 = ncread(file1,'/PRODUCT/longitude');
y1 = ncread(file1,'/PRODUCT/latitude');
z1 = ncread(file1,'/PRODUCT/nitrogendioxide_tropospheric_column') ;
x2 = ncread(file2,'/PRODUCT/longitude');
y2 = ncread(file2,'/PRODUCT/latitude');
z2 = ncread(file2,'/PRODUCT/nitrogendioxide_tropospheric_column') ;
% Make my gird
xx0 = min(min(x1(:)),min(x2(:)));
xx1 = max(max(x1(:)),max(x2(:)));
yy0 = min(min(y1(:)),min(y2(:)));
yy1 = max(max(y1(:)),max(y2(:)));
% DEfine your resolutions needed
dx = 0.5 ; dy = 0.5 ;
[X,Y] = meshgrid(xx0:dx:xx1,yy0:dy:yy1) ;
F1 = scatteredInterpolant(x1(:),y1(:),z1(:),'nearest','none') ;
Z1 = F1(X,Y) ;
F2 = scatteredInterpolant(x2(:),y2(:),z2(:),'nearest','none') ;
Z2 = F2(X,Y) ;
Z = (Z1+Z2)/2 ;
pcolor(X,Y,Z)
shading interp

4 comentarios

Sreeraj R
Sreeraj R el 11 de Oct. de 2021
Editada: Sreeraj R el 11 de Oct. de 2021
thank you sir, but this can be only used to display the images.. however i need to make a separate .nc file with all these paramaetrs from both the files. how do i save that file?
Sreeraj R
Sreeraj R el 11 de Oct. de 2021
and the images overlaps in some parts, how do i formulate a code to just consider one image and ignore the other in these overlapping areas?
KSSV
KSSV el 11 de Oct. de 2021
A coomonn grid is made and average of both the results are carried out. To write to nc use ncwrite.
Sreeraj R
Sreeraj R el 11 de Oct. de 2021
thank you sir

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 11 de Oct. de 2021

Comentada:

el 11 de Oct. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by