36
36
37
37
logger = logging .getLogger (__name__ )
38
38
39
- class PySL4LandUtils (object ):
39
+ def latlon_to_utm_zone_number (latitude , longitude ):
40
+ """
41
+ Find the UTM zone number for a give latitude and longitude. UTM zone will be returned for all the
42
+ lat/longs within the input arrays, which must be of the same length. Function will also work with
43
+ a single value, at which point a single int will be returned.
40
44
41
- def latlon_to_utm_zone_number (self , latitude , longitude ):
42
- """
43
- Find the UTM zone number for a give latitude and longitude. UTM zone will be returned for all the
44
- lat/longs within the input arrays, which must be of the same length. Function will also work with
45
- a single value, at which point a single int will be returned.
45
+ :param latitude: numpy array of floats
46
+ :param longitude: numpy array of floats
46
47
47
- :param latitude: numpy array of floats
48
- :param longitude: numpy array of floats
48
+ :return: int or array of ints.
49
49
50
- :return: int or array of ints.
50
+ """
51
+ import numpy
52
+ utm_zones = (((longitude + 180 ) / 6 ) + 1 )
53
+ utm_zones = numpy .rint (utm_zones ).astype (int )
51
54
52
- """
53
- import numpy
54
- utm_zones = (((longitude + 180 ) / 6 ) + 1 )
55
- utm_zones = numpy .rint (utm_zones ).astype (int )
55
+ utm_zones [(56 <= latitude ) & (latitude < 64 ) & (3 <= longitude ) & (longitude < 12 )] = 32
56
+ utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 9 )] = 31
57
+ utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 21 )] = 33
58
+ utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 33 )] = 35
59
+ utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 42 )] = 37
56
60
57
- utm_zones [(56 <= latitude ) & (latitude < 64 ) & (3 <= longitude ) & (longitude < 12 )] = 32
58
- utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 9 )] = 31
59
- utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 21 )] = 33
60
- utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 33 )] = 35
61
- utm_zones [(72 <= latitude ) & (latitude <= 84 ) & (longitude >= 0 ) & (longitude < 42 )] = 37
61
+ return utm_zones
62
62
63
- return utm_zones
63
+ def latlon_to_mode_utm_zone_number (latitude , longitude ):
64
+ """
65
+ Find the mode UTM zone for a list of lat/lon values.
64
66
65
- def latlon_to_mode_utm_zone_number ( self , latitude , longitude ):
66
- """
67
- Find the mode UTM zone for a list of lat/lon values.
67
+ :param latitude: numpy array of floats
68
+ :param longitude: numpy array of floats
69
+ :return: int ( mode UTM zone)
68
70
69
- :param latitude: numpy array of floats
70
- :param longitude: numpy array of floats
71
- :return: int (mode UTM zone)
71
+ """
72
+ import scipy .stats
73
+ utm_zones = latlon_to_utm_zone_number (latitude , longitude )
74
+ mode , count = scipy .stats .mode (utm_zones )
75
+ return mode [0 ]
72
76
73
- """
74
- import scipy .stats
75
- utm_zones = self .latlon_to_utm_zone_number (latitude , longitude )
76
- mode , count = scipy .stats .mode (utm_zones )
77
- return mode [0 ]
0 commit comments