hi @svniemeijer thanks for taking the time to help with questions. I am also trying to automate this process of rater creation using python. I have a couple of questions i hoped you could help me with.
The example i chose was a methane product (google drive file link): “S5P_OFFL_L2__CH4_____010300_20190417T054418.nc”
The docs seem to say the images are 7 x 7 km, and images plotted by @luisgpaixao look the right shape, but when i plot this methane product (using panoply here) i get a long strip:
Given each ‘pixel’ has a lat/long I converted the grid to vector points (python snippet below).
printing the lat.min(), lat.max(),lon.min(), lon.max() extents and I get the whole world!
west:-179.9999237060547, south:-89.92754364013672, east:179.9989013671875, north:89.9327392578125
I’m assuming the extreme lats because the strip genuinely seems to got from pole to pole; in which case the extreme longitudes are because the data covers one of the poles where the longitudes are very close together. This is more obvious in a plot of the points from the csv
Anyway, is this data such a long strip because it is a different swath capture (akin to IW, EW etc for sentinel-1); or is it captured differently like this for the methane product?
You mentioned that the harp caommandline tool can bin the data into a regular grid.
Could you show us how to call the same functionality directly within python? I could always call the same tool you mentioned via subprocess(), but it would be great to import the harp api directly and apply the methods from within python.
When interpolating/binning to a geotiff grid, could one simply pass to harp the extents as printed above for this product, even though they are so extreme, or will defining the geodesic ‘wgs84’ simply handle this?
Thanks in advance!
Ryan
@dmichelakis interesitng?
Python snippet used to generate points:
data = Path(r'/home/vagrant/projects/data/nc_files')
data.exists()
methane_variable = 'methane_mixing_ratio_bias_corrected'
netcdf_file = list(data.glob('*S5P_OFFL_L2__CH4____20190411T035326_20190411T053456_07729_01_010300_20190417T054418.nc'))[0]
#netcdf_file = netcdf_list[1] #S5P_OFFL_L2__CH4____20190411T035326_20190411T053456_07729_01_010300_20190417T054418.nc
print(f'netcdf_file being used: {netcdf_file.stem}')
save_path = netcdf_file.with_name('test.tif') #still havent made this!
nc_file = netCDF4.Dataset(netcdf_file)['/PRODUCT']
lat = nc_file['latitude']
lon = nc_file['longitude']
west, south, east, north = [lon.min(), lat.min(), lon.max(), lat.max()]
print(f'west:{west}, south:{south}, east:{east}, north:{north}')