I am encountering some issues with spatial extent and CRS when processing the .nc4 data downloaded from GPM IMERG Final Precipitation L3 1-day 0.1° x 0.1° V07 (GPM_3IMERGDF) - https://search.earthdata.nasa.gov/search?q=GPM_3IMERGDF_07&lat=-0.0703125.
Project Overview:
My objective is to download daily precipitation data and use zonal statistics to calculate the daily average precipitation for each village in the Philippines.
Steps Taken:
1. I downloaded IMERG V07 files from Earthdata (e.g., 3B-DAY.MS.MRG.3IMERG.20110110-S000000-E235959.V07B.nc4) and imported them into R as raster data.
2. I uploaded a shapefile containing ADM4 administrative boundaries for the Philippines.
Upon inspection, I noticed the following issues:
1. The .nc4 file lacks a CRS.
2. The longitude and latitude in the spatial extent are flipped.
Challenges Faced:
1. Missing CRS:
Without the correct CRS, aligning the data with the shapefile fails during zonal statistics calculations.
2. Flipped Spatial Extent:
1)Attempting to correct the extent with R code (ext(raster_data) <- c(current_extent[3],
current_extent[4], current_extent[1], current_extent[2])) results in incorrect precipitation values.
2)Using t(raster_data$precipitation) to transpose the raster also produces invalid results.
3)Attempts to correct the file in QGIS were unsuccessful.
Request for Guidance:
Could you please help address these issues:
1. The missing CRS and the flipped spatial extent in the .nc4 files from GPM IMERG V07?
2. Suggestions for the correct steps to align these files with my shapefile for ADM4 in the Philippines?
Additional Query:
I noticed that the GPM IMERG Final Precipitation L3 1-day data can be visualized and directly downloaded as .tif files from GIOVANNI, which perfectly aligns with my shapefile. However, downloading daily data from 2005-01-01 to 2020-12-31 involves more than 5,000 files, which makes manual download impractical. I try to automate this process using the RSelenium package in R, but it was unsuccessful.
Could you please advise on how to batch download .tif files directly from GIOVANNI or an alternative method to automate this process?
Thank you very much for your time and help. I deeply appreciate your help in addressing these issues!
Assistance Required: Spatial Extent and CRS Issues with GPM IMERG V07 Data
-
- User Services
- Posts: 4
- Joined: Tue Dec 17, 2024 7:46 am America/New_York
Re: Assistance Required: Spatial Extent and CRS Issues with GPM IMERG V07 Data
All IMERG dataset are written in "column-major", or "transposed" format. This is perfectly fine, because dimension variables in the HDF5/nc4 files of these datasets are sufficient to describe this.
Depending on your programming skills, and for those users who may find it problematic, there are several ways to deal with it. If you are uncomfortable using programming languages (IDL, Python, etc. ), the easiest is probably to instal the newest gdal (may be 3.9) package, and in particular the "gdal_translate" utility. Then you would script one-line commands like:
gdal_translate -a_srs EPSG:4326 -of GTiff -a_gt 180 0 -0.1 -90 0.1 0 "NETCDF:"""3B-DAY.MS.MRG.3IMERG.20240601-S000000-E235959.V07B.nc4""":precipitation" 3B-DAY.MS.MRG.3IMERG.20240601-S000000-E235959.V07B.tif
I'd strongly recommend to familiarize with the gdal_translate user guide, if going that route:
https://gdal.org/en/stable/programs/gdal_translate.html
Another way is using QGIS and a plugin created by Eugene Yu for this purpose (pls give proper credits to the author):
https://github.com/eugenegesdisc/gpm-grid-data-reader
While I know things in QGIS can be batch-processed, I never attempted that because my personal preference is to script these sort of things in IDL - reading/transposing data arrays, and then writing to GeoTIFF. I'm certain same goes if you'd do this in Python/MatLab/etc..
Last couple of notes:
1. gdal_translate is available in QGIS, and you wouldn't need the plugin, but you must make certain the QGIS is packaged with Gdal verion 3.9 or higher.
2. Recent versions of ArcGIS Pro honor dimension variables in IMERG, and would directly read/plot these data correctly without any extra preprocessing.
Depending on your programming skills, and for those users who may find it problematic, there are several ways to deal with it. If you are uncomfortable using programming languages (IDL, Python, etc. ), the easiest is probably to instal the newest gdal (may be 3.9) package, and in particular the "gdal_translate" utility. Then you would script one-line commands like:
gdal_translate -a_srs EPSG:4326 -of GTiff -a_gt 180 0 -0.1 -90 0.1 0 "NETCDF:"""3B-DAY.MS.MRG.3IMERG.20240601-S000000-E235959.V07B.nc4""":precipitation" 3B-DAY.MS.MRG.3IMERG.20240601-S000000-E235959.V07B.tif
I'd strongly recommend to familiarize with the gdal_translate user guide, if going that route:
https://gdal.org/en/stable/programs/gdal_translate.html
Another way is using QGIS and a plugin created by Eugene Yu for this purpose (pls give proper credits to the author):
https://github.com/eugenegesdisc/gpm-grid-data-reader
While I know things in QGIS can be batch-processed, I never attempted that because my personal preference is to script these sort of things in IDL - reading/transposing data arrays, and then writing to GeoTIFF. I'm certain same goes if you'd do this in Python/MatLab/etc..
Last couple of notes:
1. gdal_translate is available in QGIS, and you wouldn't need the plugin, but you must make certain the QGIS is packaged with Gdal verion 3.9 or higher.
2. Recent versions of ArcGIS Pro honor dimension variables in IMERG, and would directly read/plot these data correctly without any extra preprocessing.