-
Notifications
You must be signed in to change notification settings - Fork 265
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
Exporting a shapefile using save_qgis.py error #1300
Comments
Potential solutionThe bug is caused by the What is causing this bug?The bug is caused by the
CodeTo address the bug, we can implement the following changes:
import h5py
def validate_geometry_file(geom_file):
with h5py.File(geom_file, 'r') as f:
if 'latitude' not in f or 'longitude' not in f:
raise ValueError("Geometry file must contain 'latitude' and 'longitude' datasets.")
def get_lat_lon(metadata, geom_file=None, box=None):
if geom_file:
with h5py.File(geom_file, 'r') as f:
if 'latitude' not in f or 'longitude' not in f:
raise ValueError("Geometry file is missing 'latitude' and 'longitude' datasets.")
elif 'Y_FIRST' not in metadata or 'X_FIRST' not in metadata:
raise ValueError("Metadata is not geocoded. Missing 'Y_FIRST' or 'X_FIRST'.")
# Existing logic to retrieve lat/lon
How to replicate the bug
By implementing these changes, we can ensure that the script handles the geometry file correctly and provides clear guidance when errors occur. Click here to create a Pull Request with the proposed solution Files used for this task: Changes on src/mintpy/cli/save_qgis.pyAnalysis of
|
!save_qgis.py timeseries.h5 -g inputs/geometryGeo.h5 -o ts.shp
gather auxliary data files
TimeSeries: timeseries.h5
Velocity : velocity.h5
Coherence : temporalCoherence.h5
Mask : maskTempCoh.h5
Geometry : inputs/geometryGeo.h5
output shape file: ts.shp
output shape file: ts.shp exists, will be overwritten ....
number of points with time-series: 1945177
Traceback (most recent call last):
File "/home/anaconda3/envs/opensarlab_mintpy_recipe_book/bin/save_qgis.py", line 8, in
sys.exit(main())
File "/home/anaconda3/envs/opensarlab_mintpy_recipe_book/lib/python3.9/site-packages/mintpy/cli/save_qgis.py", line 69, in main
save_qgis(inps)
File "/home/anaconda3/envs/opensarlab_mintpy_recipe_book/lib/python3.9/site-packages/mintpy/save_qgis.py", line 245, in save_qgis
write_shape_file(fDict, inps.shp_file, box=box, zero_first=inps.zero_first)
File "/home/anaconda3/envs/opensarlab_mintpy_recipe_book/lib/python3.9/site-packages/mintpy/save_qgis.py", line 169, in write_shape_file
lats, lons = ut.get_lat_lon(ts_obj.metadata, geom_file=fDict['Geometry'], box=box)
File "/home/anaconda3/envs/opensarlab_mintpy_recipe_book/lib/python3.9/site-packages/mintpy/utils/utils0.py", line 471, in get_lat_lon
raise ValueError(msg)
ValueError: Can not get pixel-wise lat/lon!
meta dict is not geocoded and/or geometry file does not contains latitude/longitude dataset.
The text was updated successfully, but these errors were encountered: