I have numerous HDF5 files(.nc) which I need to batch process warp using one of the gdal utilities gdalwarp. When I tried to warp the files an error occurred:
INPUT:
gdalwarp -geoloc -te 109.975 3.475 135.025 25.025 HDF5:"@file"://geophysical_data/chlor_a %out_path%\@fname.tif"
RESULT:
ERROR 1: Unable to compute a GEOLOC_ARRAY based transformation between pixel/lin e and georeferenced coordinates for HDF5:A2015045060500.L2_LAC_OC.nc://geophysical _data/chlor_a.
Update1:
Just to make it clear, do you mean in lat.vrt, lon.vrt and chlor.vrt I should remove the GCP Id's and MDI key and insert this section:
oc-long.vrt
1
oc-lat.vrt
1
0
0
1
1
in between this section?
###### metadata section here #######
HDF5:A2015194044000.L2_LAC.SeAHABS.nc://geophysical_data/chlor_a
1
Answer
After some testing, I think that the geoloc is not working properly. So I used the alternative method using manually created vrt files:
- Create a file named
lon.vrt
:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]
HDF5:A2015045060000.L2_LAC_OC.nc://navigation_data/longitude
1
- Same for the latitudes in
lat.vrt
:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]
HDF5:A2015045060000.L2_LAC_OC.nc://navigation_data/latitude
1
- and for the data
chlor.vrt
:
lon.vrt
1
lat.vrt
1
0
0
1
1
HDF5:A2015045060000.L2_LAC_OC.nc://geophysical_data/chlor_a
1
- Do the warping with:
gdalwarp -geoloc -t_srs EPSG:4326 chlor.vrt chlor-out.tif
and the result fits to the shorelines around Borneo:
Alternatively to creating the vrts manually, you can create them with GDAL:
gdal_translate -of VRT HDF5:A2015045060000.L2_LAC_OC.nc://navigation_data/longitude lon.vrt
gdal_translate -of VRT HDF5:A2015045060000.L2_LAC_OC.nc://navigation_data/latitude lat.vrt
gdal_translate -of VRT HDF5:A2015045060000.L2_LAC_OC.nc://geophysical_data/chlor_a chlor.vrt
With a good text editor, remove the GCP lists from all of them, and insert only into the chlor.vrt this section instead:
lon.vrt
1
lat.vrt
1
0
0
1
1
Then run
gdalwarp -geoloc -t_srs EPSG:4326 -overwrite chlor.vrt chlor-vrt.tif
to get the same picture as above.
Another solution, working with manually edited GCP points, can be found in my answer for Using GDALwarp for reprojecting netCDF file?
No comments:
Post a Comment