-
Notifications
You must be signed in to change notification settings - Fork 260
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
The discrepancy in latitude and longitude when displayed in QGIS #1286
Comments
👋 Thanks for opening your first issue here! Please filled out the template with as much details as possible. We appreciate that you took the time to contribute! |
Potential solutionThe plan to solve the bug involves verifying and correcting the geotransform parameters and the coordinate reference system (CRS) used when converting the MintPy-generated HDF5 files to GeoTIFF format. The discrepancy in latitude and longitude alignment in QGIS is likely due to incorrect geotransform settings or an inappropriate EPSG code being applied. By ensuring that the metadata accurately reflects the spatial properties of the data and that the correct CRS is used, we can resolve the misalignment issue. What is causing this bug?The bug is likely caused by incorrect geotransform parameters or an inappropriate EPSG code being applied during the conversion process. The geotransform parameters ( CodeTo address the issue, we need to ensure that the geotransform parameters and CRS are correctly set. Here is a code snippet that demonstrates how to verify and set these parameters: from osgeo import gdal, osr
def convert_to_geotiff(input_h5, output_tif, metadata):
# Open the input HDF5 file
dataset = gdal.Open(input_h5, gdal.GA_ReadOnly)
# Extract geotransform parameters from metadata
x_first = metadata.get('X_FIRST', None)
x_step = metadata.get('X_STEP', None)
y_first = metadata.get('Y_FIRST', None)
y_step = metadata.get('Y_STEP', None)
if None in [x_first, x_step, y_first, y_step]:
raise ValueError("Geotransform parameters are missing from metadata.")
# Set geotransform
geotransform = (x_first, x_step, 0, y_first, 0, y_step)
# Create output GeoTIFF
driver = gdal.GetDriverByName('GTiff')
out_dataset = driver.CreateCopy(output_tif, dataset, 0)
out_dataset.SetGeoTransform(geotransform)
# Set the correct CRS
srs = osr.SpatialReference()
epsg_code = metadata.get('EPSG', None)
if epsg_code:
srs.ImportFromEPSG(int(epsg_code))
else:
raise ValueError("EPSG code is missing from metadata.")
out_dataset.SetProjection(srs.ExportToWkt())
out_dataset.FlushCache()
print(f"GeoTIFF saved to {output_tif} with geotransform and CRS set correctly.")
# Example usage
metadata = {
'X_FIRST': 100.0,
'X_STEP': 0.0001,
'Y_FIRST': 0.0,
'Y_STEP': -0.0001,
'EPSG': '32633' # Example EPSG code
}
convert_to_geotiff('geo_temporalCoherence.h5', 'output.tif', metadata) How to replicate the bug
By following these steps, you should be able to replicate the misalignment issue in QGIS. Click here to create a Pull Request with the proposed solution Files used for this task: Changes on src/mintpy/save_gdal.pyBased on the provided code in
In summary, the potential cause of the discrepancy could be related to incorrect geotransform parameters, an inappropriate EPSG code, or metadata issues. It would be beneficial to verify these aspects in the metadata of the input files and ensure they are correctly applied during the conversion process. Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect. Current plan usage: 0.00% Have feedback or need help? |
@kyutecdaichi could you check the alignment of the KMZ file in Google Earth? If there is misalignment there as well, then the problem is in the data itself, due to the inaccurate geolocation, probably from the reference image used in coregistration while running |
@yunjunz Thank you for your response. |
Use a reference date in 2019 for coregistration, to avoid potential ionospheric displacement. How big is this misalignment you observed? |
Is it possible that you are using ALOS-2, processed with isce2/stripmapStack, and forgot to run |
I am using Sentinel-1 data, not ALOS-2 data. Therefore, I am using the isce2/topsStack's stackSentinel.py for processing. |
Interesting. Could you post your basic data info here?
|
I am currently conducting InSAR analysis using ISCE2-MintPy with Sentinel data.
However, when I convert the geo_temporalCoherence.h5 or geo_velocity.h5 files generated by MintPy to GeoTIFF format (.tif) and display them in QGIS, there is a slight misalignment in the images.
I am unsure about the cause or how to resolve this issue. If anyone knows the reason or has a solution, please let me know. I would greatly appreciate your help.
Thank you!
The text was updated successfully, but these errors were encountered: