本文整理汇总了Python中utm.from_latlon方法的典型用法代码示例。如果您正苦于以下问题:Python utm.from_latlon方法的具体用法?Python utm.from_latlon怎么用?Python utm.from_latlon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utm
的用法示例。
在下文中一共展示了utm.from_latlon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_pix_lstring_to_geo
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def convert_pix_lstring_to_geo(wkt_lstring, im_file):
'''Convert linestring in pixel coords to geo coords'''
shape = wkt_lstring # shapely.wkt.loads(lstring)
x_pixs, y_pixs = shape.coords.xy
coords_latlon = []
coords_utm = []
for (x, y) in zip(x_pixs, y_pixs):
lon, lat = apls_utils.pixelToGeoCoord(x, y, im_file)
[utm_east, utm_north, utm_zone, utm_letter] = utm.from_latlon(lat, lon)
coords_utm.append([utm_east, utm_north])
coords_latlon.append([lon, lat])
lstring_latlon = LineString([Point(z) for z in coords_latlon])
lstring_utm = LineString([Point(z) for z in coords_utm])
return lstring_latlon, lstring_utm, utm_zone, utm_letter
###############################################################################
示例2: updateExtent
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def updateExtent(self):
if self._scene.cols == 0 or self._scene.rows == 0:
return
self.cols = self._scene.cols
self.rows = self._scene.rows
(self.llEutm,
self.llNutm,
self.utm_zone,
self.utm_zone_letter) = utm.from_latlon(self.llLat, self.llLon)
self.E = None
self.N = None
self.gridE = None
self.gridN = None
self._meter_grid = None
self.coordinates = None
self.config.regularize()
self.evChanged.notify()
示例3: test_from_latlon_range_checks
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def test_from_latlon_range_checks(self):
'''from_latlon should fail with out-of-bounds input'''
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, -100, 0)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, -80.1, 0)
for i in range(-8000, 8400):
UTM.from_latlon(i / 100.0, 0)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 84.1, 0)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 100, 0)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 0, -300)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 0, -180.1)
for i in range(-18000, 18000):
UTM.from_latlon(0, i / 100.0)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 0, 180.1)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 0, 300)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, -100, -300)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 100, -300)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, -100, 300)
self.assertRaises(UTM.OutOfRangeError, UTM.from_latlon, 100, 300)
示例4: latlong
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def latlong(pos, zone=None, origin=None):
"""Convert local coordinate system position to latitude/longitude.
To convert a UTM position into a global latitude/longitude, the local coordinate
system has to be specified in terms of a UTM zone 2-tuple, e.g. ``(32, 'U')``.
Alternatively a local coordinate system can be specified in terms of an origin
latitude/longitude.
"""
opos = (0,0)
if origin is not None:
if zone is not None:
raise ValueError('zone and origin cannot be concurrently specified')
origin = _normalize(origin)
opos = _utm.from_latlon(origin[0], origin[1])
zone = (opos[2], opos[3])
geo = _utm.to_latlon(pos[0]+opos[0], pos[1]+opos[1], zone[0], zone[1])
return (geo[0], geo[1], 0.0 if len(pos) < 3 else pos[2])
示例5: __init__
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def __init__(self, primaryData):
self.id = str(uuid.uuid4())
self.griddedCount = 0
self.griddedMatched = 0
self.insituCount = len(primaryData)
self.insituMatches = 0
self.primary = primaryData
for r in self.primary:
r["matches"] = []
self.data = []
for s in primaryData:
u = utm.from_latlon(s["y"], s["x"])
v = (u[0], u[1], 0.0)
self.data.append(v)
if len(self.data) > 0:
self.tree = spatial.KDTree(self.data)
else:
self.tree = None
示例6: __getChunkIndexesForLatLon
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def __getChunkIndexesForLatLon(self, chunk, lat, lon, xyTolerance):
foundIndexes = []
foundLatLons = []
if "swathIndexing" not in chunk.__dict__:
self.__buildSwathIndexes(chunk)
tree = chunk.swathIndexing["tree"]
if tree is not None:
indexes = chunk.swathIndexing["indexes"]
latlons = chunk.swathIndexing["latlons"]
u = utm.from_latlon(lat, lon)
coords = np.array([u[0], u[1], 0])
ball = tree.query_ball_point(coords, xyTolerance)
for i in ball:
foundIndexes.append(indexes[i])
foundLatLons.append(latlons[i])
return foundIndexes, foundLatLons
示例7: data_gen
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def data_gen(self):
for time, states in self.reader:
for state in states:
easting, northing, zone_num, northern = utm.from_latlon(
*state.state_vector[self.mapping[::-1], :],
self.zone_number)
if self.zone_number is None:
self.zone_number = zone_num
if self.northern is None:
self.northern = northern >= 'N'
elif (self.northern and northern < 'N') or (
not self.northern and northern >= 'N'):
warnings.warn("State cannot be converted to UTM zone")
continue
state.state_vector[self.mapping, 0] = easting, northing
yield time, states
示例8: get_node_geo_coords
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def get_node_geo_coords(G, im_file, verbose=False):
nn = len(G.nodes())
for i, (n, attr_dict) in enumerate(G.nodes(data=True)):
if verbose:
print("node:", n)
if (i % 1000) == 0:
print("node", i, "/", nn)
x_pix, y_pix = attr_dict['x_pix'], attr_dict['y_pix']
lon, lat = apls_utils.pixelToGeoCoord(x_pix, y_pix, im_file)
[utm_east, utm_north, utm_zone, utm_letter] =\
utm.from_latlon(lat, lon)
attr_dict['lon'] = lon
attr_dict['lat'] = lat
attr_dict['utm_east'] = utm_east
attr_dict['utm_zone'] = utm_zone
attr_dict['utm_letter'] = utm_letter
attr_dict['utm_north'] = utm_north
attr_dict['x'] = lon
attr_dict['y'] = lat
if verbose:
print(" ", n, attr_dict)
return G
###############################################################################
示例9: set_oxt
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def set_oxt(self, fields):
fields = [float(f) for f in fields]
self.latlon = fields[:2]
location = utm.from_latlon(*self.latlon)
self.position = np.array([location[0], location[1], fields[2]])
self.roll = fields[3]
self.pitch = fields[4]
self.yaw = fields[5]
rotation = angle2rot(np.array([self.roll, self.pitch, self.yaw]))
magic_rot = angle2rot(np.array([np.pi / 2, -np.pi / 2, 0]), inverse=True)
self.rotation = rotation.dot(magic_rot.T)
# Same as angle2rot from kio_slim
示例10: get_utm_from_wgs84
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def get_utm_from_wgs84(lng, lat):
""" Convert from WGS84 to UTM coordinate system
:param lng: Longitude
:type lng: float
:param lat: Latitude
:type lat: float
:return: UTM coordinates
:rtype: tuple
"""
_, _, zone, _ = utm.from_latlon(lat, lng)
direction = 'N' if lat >= 0 else 'S'
return CRS['UTM_{}{}'.format(str(zone), direction)]
示例11: gps_to_utm
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def gps_to_utm(gps_dic):
"""Converts Lat/Lon coordinates into UTM coordinates"""
utm_dic = OrderedDict()
for file_name in gps_dic.keys():
lat, log = gps_dic[file_name][0], gps_dic[file_name][1]
holder = from_latlon(lat, -log) #changes lat, log to utm values (EASTING, NORTHING, ZONE NUMBER, ZONE LETTER)
'''Pitt is in zone 17 so we choice not to return this now because only easting and northing is needed'''
utm_dic[file_name] = (holder[0], holder[1])
return utm_dic
示例12: test_from_latlon
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def test_from_latlon(self):
'''from_latlon should give known result with known input'''
for latlon, utm, _ in self.known_values:
result = UTM.from_latlon(*latlon)
self.assert_utm_equal(utm, result)
示例13: test_inside
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def test_inside(self):
self.assert_zone_equal(UTM.from_latlon(56, 3), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(56, 6), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(56, 9), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(56, 11.999999), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 3), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 6), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 9), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 11.999999), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 3), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 6), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 9), 32, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 11.999999), 32, 'V')
示例14: test_left_of
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def test_left_of(self):
self.assert_zone_equal(UTM.from_latlon(55.999999, 2.999999), 31, 'U')
self.assert_zone_equal(UTM.from_latlon(56, 2.999999), 31, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 2.999999), 31, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 2.999999), 31, 'V')
self.assert_zone_equal(UTM.from_latlon(64, 2.999999), 31, 'W')
示例15: test_right_of
# 需要导入模块: import utm [as 别名]
# 或者: from utm import from_latlon [as 别名]
def test_right_of(self):
self.assert_zone_equal(UTM.from_latlon(55.999999, 12), 33, 'U')
self.assert_zone_equal(UTM.from_latlon(56, 12), 33, 'V')
self.assert_zone_equal(UTM.from_latlon(60, 12), 33, 'V')
self.assert_zone_equal(UTM.from_latlon(63.999999, 12), 33, 'V')
self.assert_zone_equal(UTM.from_latlon(64, 12), 33, 'W')