def test_lonlat2xy_doubles(self): """ Tests lonlat to xy projection using double numbers. """ utm = UTMGrid(500) x_should = 433124.249310 y_should = 5338921.352324 lon, lat = 14.1, 48.2 sgrid_id, x, y = utm.lonlat2xy(lon, lat) assert sgrid_id == 'Z33N' nptest.assert_allclose(x_should, x) nptest.assert_allclose(y_should, y)
def test_lonlat2xy_numpy_array_wrong_subgrid(self): """ Tests lonlat to xy projection giving a wrong subgrid. """ utm = UTMGrid(500) x_should = np.array([-5028208.49022517]) y_should = np.array([20666035.74265257]) lon = np.array([-15.1]) lat = np.array([45.3]) sgrid_id, x, y = utm.lonlat2xy(lon, lat, subgrid='Z44S') nptest.assert_array_equal(sgrid_id, np.array(['Z44S'])) nptest.assert_allclose(x_should, x) nptest.assert_allclose(y_should, y)
def test_lonlat2xy_numpy_array_subgrid(self): """ Tests lonlat to xy projection using numpy arrays. """ utm = UTMGrid(500) x_should = np.array([492159.707973]) y_should = np.array([5016282.339957]) lon = np.array([-15.1]) lat = np.array([45.3]) sgrid_id, x, y = utm.lonlat2xy(lon, lat, subgrid='Z28N') nptest.assert_array_equal(sgrid_id, np.array(['Z28N'])) nptest.assert_allclose(x_should, x) nptest.assert_allclose(y_should, y)
def test_lonlat2xy_numpy_array(self): """ Tests lonlat to xy projection using numpy arrays. """ utm = UTMGrid(500) x_should = np.array([507840.292027, 210029.47]) y_should = np.array([4983717.660043, 6820022.61]) lon = np.array([15.1, 3.564943]) lat = np.array([-45.3, 61.405307]) sgrid_id, x, y = utm.lonlat2xy(lon, lat) nptest.assert_array_equal(sgrid_id, np.array(['Z33S', 'Z32N'])) nptest.assert_allclose(x_should, x) nptest.assert_allclose(y_should, y)