bpostance / learn_data_engineering

2 stars 5 forks source link

rasterio and gdalwarp code mentioned #8

Open devosse1 opened 1 year ago

devosse1 commented 1 year ago

`for fl in usa_files[:]:
in_file = f"./data/raw/{fl}" out_file = f"./data/transformed/{fl.replace('.hdf','.tif')}"

# open dataset
dataset = gdal.Open(in_file,gdal.GA_ReadOnly)
subdataset =  gdal.Open(dataset.GetSubDatasets()[0][0], gdal.GA_ReadOnly)

# gdalwarp
kwargs = {'format': 'GTiff', 'dstSRS': 'EPSG:4326'}
ds = gdal.Warp(destNameOrDestDS=out_file,srcDSOrSrcDSTab=subdataset, **kwargs)
del ds`

This works for one of the layers in multilayer file. I have modis LST .hdf and it has multiple subdatasets(daytime LST , NighttimeLST, View angle..etc) and I want to transform it from sinusoidal to 'EPSG:4326' into a single file geotiff or .nc. The rasterio code of yours also didn't work. Can you please help with it

bpostance commented 1 year ago

Sure. Can you share a link to an example file you’re trying to work with.

devosse1 commented 1 year ago

MOD11A1-Copy1.A2015002.h24v06.061.2021347092632.zip The above I was able to reproject eaily with rio.reproject of rioxarray

I don't know if you can help but I have a geostationary lst file with central latitude at 81 deg , I want to convert to mercator I am not able to do it

bpostance commented 1 year ago

Do you have a link to the website source so I can see metadata and instructions etc.

devosse1 commented 1 year ago

https://stackoverflow.com/questions/75637698/reprojection-of-insat-geostationary-h5-file-to-epsg4326?noredirect=1#comment133455210_75637698 , let me know if additional details needed

bpostance commented 1 year ago

Please can you share the web link to where you download the data? I.e the website you are downloading the raw data from (not your Google drive)I want to check any instructions the source / publishers provide on data formatting etc.