Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDF5: issue with GCPs and nodata #1451

Closed
NidhiPal619 opened this issue Apr 17, 2019 · 2 comments
Closed

HDF5: issue with GCPs and nodata #1451

NidhiPal619 opened this issue Apr 17, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@NidhiPal619
Copy link

Hello all,
I am trying to reproject a netCDF file using the gdalwarp command. However, the gdalwarp is giving me a black output. Below is my code:
import gdal
import osr
import netCDF4
from osgeo.gdalconst import *
import os
import subprocess

gdal.AllRegister()
file_nc = 'input.nc'
ds = gdal.Open(file_nc, GA_ReadOnly)
Dataset = ds.GetSubDatasets()
#driver = gdal.GetDriverByName('GTiff')

substr = 'Rrs_655'
band = ''
names = [i[0] for i in Dataset]
for word in names[:]:
if word.endswith(substr):
band = word
b = 'gdal_translate -a_scale 0.000002 -a_offset 0.05 -a_nodata -32767 '+ band + ' output13.tif'
print(b)
subprocess.run(b, shell = True)
cmd = 'gdalwarp output13.tif outfile2.tif -t_srs "+proj=longlat +ellps=WGS84"'
subprocess.run(cmd, shell = True)

The gdalinfo of output13.tif band is:
Files: output13.tif
Size is 7821, 7931
Coordinate System is `'
GCP Projection =
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 7931.0)
Upper Right ( 7821.0, 0.0)
Lower Right ( 7821.0, 7931.0)
Center ( 3910.5, 3965.5)
Band 1 Block=7821x1 Type=Int16, ColorInterp=Gray
NoData Value=-32767
Offset: 0.05, Scale:2e-06
Metadata:
geophysical_data_Rrs_655_add_offset=0.050000001
geophysical_data_Rrs_655_long_name=Remote sensing reflectance at 655 nm
geophysical_data_Rrs_655_scale_factor=2e-06
geophysical_data_Rrs_655_solar_irradiance=1550.3799
geophysical_data_Rrs_655_standard_name=surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air
geophysical_data_Rrs_655_units=sr^-1
geophysical_data_Rrs_655_valid_max=25000
geophysical_data_Rrs_655_valid_min=-30000
geophysical_data_Rrs_655__FillValue=-32767

The gdalinfo if the file outfile2.tif is:
Files: outfile2.tif
Size is 12259, 12307
Coordinate System is:
GEOGCS["WGS 84",
DATUM["unknown",
SPHEROID["WGS84",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]]
Origin = (-20696.575935146218399,3354.169516545325678)
Pixel Size = (1.950162663734099,-1.950162663734099)
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( -20696.576, 3354.170) (Invalid angle,Invalid angle)
Lower Left ( -20696.576, -20646.482) (Invalid angle,Invalid angle)
Upper Right ( 3210.468, 3354.170) (Invalid angle,Invalid angle)
Lower Right ( 3210.468, -20646.482) (Invalid angle,Invalid angle)
Center ( -8743.054, -8646.156) (Invalid angle,Invalid angle)
Band 1 Block=12259x1 Type=Int16, ColorInterp=Gray
NoData Value=-32767
Metadata:
geophysical_data_Rrs_655_add_offset=0.050000001
geophysical_data_Rrs_655_long_name=Remote sensing reflectance at 655 nm
geophysical_data_Rrs_655_scale_factor=2e-06
geophysical_data_Rrs_655_solar_irradiance=1550.3799
geophysical_data_Rrs_655_standard_name=surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air
geophysical_data_Rrs_655_units=sr^-1
geophysical_data_Rrs_655_valid_max=25000
geophysical_data_Rrs_655_valid_min=-30000
geophysical_data_Rrs_655__FillValue=-32767

Any type of help is appreciated.

Best,
Nidhi

@rouault
Copy link
Member

rouault commented Apr 17, 2019

It is not possible to diagnose if it is an issue in your code or in GDAL with what you provided.
Please:

  • provide links or attachements to the input dataset
  • and provide only command lines to reproduce the issue as I don't think the Python part is relevant

@rouault rouault added the awaiting_feedback Awaiting feedback from reporter label Apr 17, 2019
@NidhiPal619
Copy link
Author

Here is the link to the input.nc file: https://drive.google.com/file/d/1xw6OB0oZhOde0Lb4x3YJLe4hyyDfO2vu/view?usp=sharing
The commands that I am using are:

  1. gdal_translate -a_scale 0.000002 -a_offset 0.05 -a_nodata -32767 HDF5:"input.nc"://geophysical_data/Rrs_655 output13.tif
  2. gdalwarp output13.tif outfile2.tif -t_srs "+proj=longlat +ellps=WGS84"

Thank you!

@rouault rouault removed the awaiting_feedback Awaiting feedback from reporter label Apr 17, 2019
@rouault rouault self-assigned this Apr 17, 2019
@rouault rouault added the bug label Apr 17, 2019
rouault added a commit that referenced this issue Apr 17, 2019
…r accepting datasets for GCP, and handle nodata in GCP too (fixes #1451)
@rouault rouault added this to the 2.4.2 milestone Apr 17, 2019
@rouault rouault changed the title Gdalwarp re-projection HDF5: issue with GCPs and nodata Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants