Closed YingzhiGou closed 6 years ago
Also in the mtpy/utils/shapefiles.py, there are similar functions: def transform_utm_to_ll(easting, northing, zone, reference_ellipsoid='WGS84'):
def transform_ll_to_utm(lon, lat, reference_ellipsoid='WGS84'):
Yingzhi, can you test, refactor them, removing duplications
mtpy/utils/latlon_utm_conversion.py does not relay on gdal and gis_tools does. latlon_utm_conversion.py does all the calculation and projection in python and for wgs84, it uses another package 'utm'.
I think the current option is to mark the functions in latlon_utm_conversion.py as deprecated and move it to legacy later. i think we should keep this code around for the situation when gdal is not available
note that the conversion in gis_tools requires gdal data is available and GDAL_DATA environment variable to be set to the gdal data directory. My experiences is some source of installation does not provide the data files, then the function call to gdal that uses the data fail will return invalid value and an error code (but does not raise any exceptions), which could lead to incorrect projection result (it actually happened in some testing before). so a guard is put in gis_tools, that will raise ImportError if the GDAL_DATA is not set or the path in GDAL_DATA cannot be found.
I will add a decorator to all the functions that require GDAL_DATA instead so that missing GDAL_DATA will not affect the functions that does not requires GDAL_DATA.
another thing we can do later is to change the decorator to call the functions from latlon_utm_conversion that does not requires GDAL_DATA if it is not available. but we need to change the return tuples of these functions so that the return format is the same (also check the returned values too)
i have merged latlon_utm_conversion.py to gis_tools. however, the result of utm2ll from both files (utm_to_ll() and project_point_utm2ll()) are incorrect.
the function mentioned in https://github.com/MTgeophysics/mtpy/issues/4#issuecomment-343779773 is not duplicate as it returns more information than others. this function is overlapping with existing ones in gis_tools.py
the code in latlon_utm_conversion.py and latlonutmconveresion.py are duplicates. the usages of each should be searched and changed to latlon_utm_conversion.py. then latlonutmconveresion.py should be deleted.
also, the functionalities of latlon_uitm_conversion.py seem to be overlapping with gis_tools.py, so the unique functionality will be merged into gis_tools.py