Skip to main content
static void Main(string[] args)
{
    //Common variables           for NZTM2000
    double a       = 6378137;
    double f       = 1 / 298.257222101;
    double phizero  = 0;
    double lambdazero  = 173;
    double Nzero   = 10000000;
    double Ezero   = 1600000;
    double kzero   = 0.9996;            

    //input Northing(Y); Easting(X) variables
    double N       = 5427502.0;
    double E       = 1749165.0;
    
    //Calculation: From NZTM to lat/Long

    double b = a * (1 - f);
    double esq = 2 * f - Math.Pow(f, 2);
    double Z0 = 1 - esq / 4 - 3 * Math.Pow(esq, 2) / 64 - 5 * Math.Pow(esq, 3) / 256;
    double A2 = 0.375 * (esq + Math.Pow(esq, 2) / 4 + 15 * Math.Pow(esq, 3) / 128);
    double A4 = 15 * (Math.Pow(esq, 2) + 3 * Math.Pow(esq, 3) / 4) / 256;
    double A6 = 35 * Math.Pow(esq, 3) / 3072;

    double Nprime = N - Nzero;
    double mprime = Nprime / kzero;
    double smn = (a - b) / (a + b);
    double G = a * (1 - smn) * (1 - Math.Pow(smn, 2)) * (1 + 9 * Math.Pow(smn, 2) / 4 + 225 * Math.Pow(smn, 4) / 64) * Math.PI/ 180.0;
    double sigma = mprime * Math.PI / (180 * G);
    double phiprime = sigma + (3 * smn / 2 - 27 * Math.Pow(smn, 3) / 32) * Math.Sin(2 * sigma) + (21 * Math.Pow(smn, 2) / 16 - 55 * Math.Pow(smn, 4) / 32) * Math.Sin(4 * sigma) + (151 * Math.Pow(smn, 3) / 96) * Math.Sin(6 * sigma) + (1097 * Math.Pow(smn, 4) / 512) *Math.Sin(8 * sigma);
    double rhoprime = a * (1 - esq) / Math.Pow((1 - esq * Math.Pow((Math.Sin(phiprime)), 2)), 1.5);
    double upsilonprime = a / Math.Sqrt(1 - esq * Math.Pow((Math.Sin(phiprime)), 2));

    double psiprime = upsilonprime / rhoprime;
    double tprime = Math.Tan(phiprime);
    double Eprime = E - Ezero;
    double chi = Eprime / (kzero * upsilonprime);
    double term_1 = tprime * Eprime * chi / (kzero * rhoprime * 2);
    double term_2 = term_1 * Math.Pow(chi, 2) / 12 * (-4 * Math.Pow(psiprime, 2) + 9 * psiprime * (1 - Math.Pow(tprime, 2)) + 12 * Math.Pow(tprime, 2));
    double term_3 = tprime * Eprime * Math.Pow(chi, 5) / (kzero * rhoprime * 720) * (8 * Math.Pow(psiprime, 4) * (11 - 24 * Math.Pow(tprime, 2)) - 12 * Math.Pow(psiprime, 3) * (21 - 71 * Math.Pow(tprime, 2)) + 15 * Math.Pow(psiprime, 2) * (15 - 98 * Math.Pow(tprime, 2) + 15 * Math.Pow(tprime, 4)) + 180 * psiprime * (5 * Math.Pow(tprime, 2) - 3 * Math.Pow(tprime, 4)) + 360 * Math.Pow(tprime, 4));
    double term_4 = tprime * Eprime * Math.Pow(chi ,7) / (kzero * rhoprime * 40320) * (1385 + 3633 * Math.Pow(tprime, 2) + 4095 * Math.Pow(tprime, 4) + 1575 * Math.Pow(tprime, 6));
    double term1 = chi * (1 / Math.Cos(phiprime));
    double term2 = Math.Pow(chi, 3) * (1 / Math.Cos(phiprime)) / 6 * (psiprime + 2 * Math.Pow(tprime, 2));
    double term3 = Math.Pow(chi, 5) * (1 / Math.Cos(phiprime)) / 120 * (-4 * Math.Pow(psiprime, 3) * (1 - 6 * Math.Pow(tprime, 2)) + Math.Pow(psiprime, 2) * (9 - 68 * Math.Pow(tprime, 2)) + 72 * psiprime * Math.Pow(tprime, 2) + 24 * Math.Pow(tprime, 4));
    double term4 = Math.Pow(chi, 7) * (1 / Math.Cos(phiprime)) / 5040 * (61 + 662 * Math.Pow(tprime, 222) + 1320 * Math.Pow(tprime, 4) + 720 * Math.Pow(tprime, 6));

    double latitude = (phiprime - term_1 + term_2 - term_3 + term_4) * 180 / Math.PI;
    double longitude = lambdazero + 180 / Math.PI * (term1 - term2 + term3 - term4);

    Console.WriteLine("Lat/Long: " + latitude.ToString() + ',' + longitude.ToString());
    Console.ReadLine();
}
static void Main(string[] args)
{
    //Common variables            
    double a       = 6378137;
    double f       = 1 / 298.257222101;
    double phizero  = 0;
    double lambdazero  = 173;
    double Nzero   = 10000000;
    double Ezero   = 1600000;
    double kzero   = 0.9996;            

    //input Northing(Y); Easting(X) variables
    double N       = 5427502.0;
    double E       = 1749165.0;
    
    //Calculation: From NZTM to lat/Long

    double b = a * (1 - f);
    double esq = 2 * f - Math.Pow(f, 2);
    double Z0 = 1 - esq / 4 - 3 * Math.Pow(esq, 2) / 64 - 5 * Math.Pow(esq, 3) / 256;
    double A2 = 0.375 * (esq + Math.Pow(esq, 2) / 4 + 15 * Math.Pow(esq, 3) / 128);
    double A4 = 15 * (Math.Pow(esq, 2) + 3 * Math.Pow(esq, 3) / 4) / 256;
    double A6 = 35 * Math.Pow(esq, 3) / 3072;

    double Nprime = N - Nzero;
    double mprime = Nprime / kzero;
    double smn = (a - b) / (a + b);
    double G = a * (1 - smn) * (1 - Math.Pow(smn, 2)) * (1 + 9 * Math.Pow(smn, 2) / 4 + 225 * Math.Pow(smn, 4) / 64) * Math.PI/ 180.0;
    double sigma = mprime * Math.PI / (180 * G);
    double phiprime = sigma + (3 * smn / 2 - 27 * Math.Pow(smn, 3) / 32) * Math.Sin(2 * sigma) + (21 * Math.Pow(smn, 2) / 16 - 55 * Math.Pow(smn, 4) / 32) * Math.Sin(4 * sigma) + (151 * Math.Pow(smn, 3) / 96) * Math.Sin(6 * sigma) + (1097 * Math.Pow(smn, 4) / 512) *Math.Sin(8 * sigma);
    double rhoprime = a * (1 - esq) / Math.Pow((1 - esq * Math.Pow((Math.Sin(phiprime)), 2)), 1.5);
    double upsilonprime = a / Math.Sqrt(1 - esq * Math.Pow((Math.Sin(phiprime)), 2));

    double psiprime = upsilonprime / rhoprime;
    double tprime = Math.Tan(phiprime);
    double Eprime = E - Ezero;
    double chi = Eprime / (kzero * upsilonprime);
    double term_1 = tprime * Eprime * chi / (kzero * rhoprime * 2);
    double term_2 = term_1 * Math.Pow(chi, 2) / 12 * (-4 * Math.Pow(psiprime, 2) + 9 * psiprime * (1 - Math.Pow(tprime, 2)) + 12 * Math.Pow(tprime, 2));
    double term_3 = tprime * Eprime * Math.Pow(chi, 5) / (kzero * rhoprime * 720) * (8 * Math.Pow(psiprime, 4) * (11 - 24 * Math.Pow(tprime, 2)) - 12 * Math.Pow(psiprime, 3) * (21 - 71 * Math.Pow(tprime, 2)) + 15 * Math.Pow(psiprime, 2) * (15 - 98 * Math.Pow(tprime, 2) + 15 * Math.Pow(tprime, 4)) + 180 * psiprime * (5 * Math.Pow(tprime, 2) - 3 * Math.Pow(tprime, 4)) + 360 * Math.Pow(tprime, 4));
    double term_4 = tprime * Eprime * Math.Pow(chi ,7) / (kzero * rhoprime * 40320) * (1385 + 3633 * Math.Pow(tprime, 2) + 4095 * Math.Pow(tprime, 4) + 1575 * Math.Pow(tprime, 6));
    double term1 = chi * (1 / Math.Cos(phiprime));
    double term2 = Math.Pow(chi, 3) * (1 / Math.Cos(phiprime)) / 6 * (psiprime + 2 * Math.Pow(tprime, 2));
    double term3 = Math.Pow(chi, 5) * (1 / Math.Cos(phiprime)) / 120 * (-4 * Math.Pow(psiprime, 3) * (1 - 6 * Math.Pow(tprime, 2)) + Math.Pow(psiprime, 2) * (9 - 68 * Math.Pow(tprime, 2)) + 72 * psiprime * Math.Pow(tprime, 2) + 24 * Math.Pow(tprime, 4));
    double term4 = Math.Pow(chi, 7) * (1 / Math.Cos(phiprime)) / 5040 * (61 + 662 * Math.Pow(tprime, 22) + 1320 * Math.Pow(tprime, 4) + 720 * Math.Pow(tprime, 6));

    double latitude = (phiprime - term_1 + term_2 - term_3 + term_4) * 180 / Math.PI;
    double longitude = lambdazero + 180 / Math.PI * (term1 - term2 + term3 - term4);

    Console.WriteLine("Lat/Long: " + latitude.ToString() + ',' + longitude.ToString());
    Console.ReadLine();
}
static void Main(string[] args)
{
    //Common variables for NZTM2000
    double a       = 6378137;
    double f       = 1 / 298.257222101;
    double phizero  = 0;
    double lambdazero  = 173;
    double Nzero   = 10000000;
    double Ezero   = 1600000;
    double kzero   = 0.9996;            

    //input Northing(Y); Easting(X) variables
    double N       = 5427502.0;
    double E       = 1749165.0;
    
    //Calculation: From NZTM to lat/Long

    double b = a * (1 - f);
    double esq = 2 * f - Math.Pow(f, 2);
    double Z0 = 1 - esq / 4 - 3 * Math.Pow(esq, 2) / 64 - 5 * Math.Pow(esq, 3) / 256;
    double A2 = 0.375 * (esq + Math.Pow(esq, 2) / 4 + 15 * Math.Pow(esq, 3) / 128);
    double A4 = 15 * (Math.Pow(esq, 2) + 3 * Math.Pow(esq, 3) / 4) / 256;
    double A6 = 35 * Math.Pow(esq, 3) / 3072;

    double Nprime = N - Nzero;
    double mprime = Nprime / kzero;
    double smn = (a - b) / (a + b);
    double G = a * (1 - smn) * (1 - Math.Pow(smn, 2)) * (1 + 9 * Math.Pow(smn, 2) / 4 + 225 * Math.Pow(smn, 4) / 64) * Math.PI/ 180.0;
    double sigma = mprime * Math.PI / (180 * G);
    double phiprime = sigma + (3 * smn / 2 - 27 * Math.Pow(smn, 3) / 32) * Math.Sin(2 * sigma) + (21 * Math.Pow(smn, 2) / 16 - 55 * Math.Pow(smn, 4) / 32) * Math.Sin(4 * sigma) + (151 * Math.Pow(smn, 3) / 96) * Math.Sin(6 * sigma) + (1097 * Math.Pow(smn, 4) / 512) *Math.Sin(8 * sigma);
    double rhoprime = a * (1 - esq) / Math.Pow((1 - esq * Math.Pow((Math.Sin(phiprime)), 2)), 1.5);
    double upsilonprime = a / Math.Sqrt(1 - esq * Math.Pow((Math.Sin(phiprime)), 2));

    double psiprime = upsilonprime / rhoprime;
    double tprime = Math.Tan(phiprime);
    double Eprime = E - Ezero;
    double chi = Eprime / (kzero * upsilonprime);
    double term_1 = tprime * Eprime * chi / (kzero * rhoprime * 2);
    double term_2 = term_1 * Math.Pow(chi, 2) / 12 * (-4 * Math.Pow(psiprime, 2) + 9 * psiprime * (1 - Math.Pow(tprime, 2)) + 12 * Math.Pow(tprime, 2));
    double term_3 = tprime * Eprime * Math.Pow(chi, 5) / (kzero * rhoprime * 720) * (8 * Math.Pow(psiprime, 4) * (11 - 24 * Math.Pow(tprime, 2)) - 12 * Math.Pow(psiprime, 3) * (21 - 71 * Math.Pow(tprime, 2)) + 15 * Math.Pow(psiprime, 2) * (15 - 98 * Math.Pow(tprime, 2) + 15 * Math.Pow(tprime, 4)) + 180 * psiprime * (5 * Math.Pow(tprime, 2) - 3 * Math.Pow(tprime, 4)) + 360 * Math.Pow(tprime, 4));
    double term_4 = tprime * Eprime * Math.Pow(chi ,7) / (kzero * rhoprime * 40320) * (1385 + 3633 * Math.Pow(tprime, 2) + 4095 * Math.Pow(tprime, 4) + 1575 * Math.Pow(tprime, 6));
    double term1 = chi * (1 / Math.Cos(phiprime));
    double term2 = Math.Pow(chi, 3) * (1 / Math.Cos(phiprime)) / 6 * (psiprime + 2 * Math.Pow(tprime, 2));
    double term3 = Math.Pow(chi, 5) * (1 / Math.Cos(phiprime)) / 120 * (-4 * Math.Pow(psiprime, 3) * (1 - 6 * Math.Pow(tprime, 2)) + Math.Pow(psiprime, 2) * (9 - 68 * Math.Pow(tprime, 2)) + 72 * psiprime * Math.Pow(tprime, 2) + 24 * Math.Pow(tprime, 4));
    double term4 = Math.Pow(chi, 7) * (1 / Math.Cos(phiprime)) / 5040 * (61 + 662 * Math.Pow(tprime, 2) + 1320 * Math.Pow(tprime, 4) + 720 * Math.Pow(tprime, 6));

    double latitude = (phiprime - term_1 + term_2 - term_3 + term_4) * 180 / Math.PI;
    double longitude = lambdazero + 180 / Math.PI * (term1 - term2 + term3 - term4);

    Console.WriteLine("Lat/Long: " + latitude.ToString() + ',' + longitude.ToString());
    Console.ReadLine();
}
added 3670 characters in body
Source Link

I've just done something similar in SQL.

  The Formula for the conversion is provided here by LINZ.

We implemented this first in Excel, and then SQL. We have shared my SQL code in this post. It may be easier for

Edit: I got bored and had a play. Here you to read/transformgo.This works.

static void Main(string[] args)
{
    //Common variables            
    double a       = 6378137;
    double f       = 1 / 298.257222101;
    double phizero  = 0;
    double lambdazero  = 173;
    double Nzero   = 10000000;
    double Ezero   = 1600000;
    double kzero   = 0.9996;            

    //input Northing(Y); Easting(X) variables
    double N       = 5427502.0;
    double E       = 1749165.0;
    
    //Calculation: From NZTM to lat/Long

    double b = a * (1 - f);
    double esq = 2 * f - Math.Pow(f, 2);
    double Z0 = 1 - esq / 4 - 3 * Math.Pow(esq, 2) / 64 - 5 * Math.Pow(esq, 3) / 256;
    double A2 = 0.375 * (esq + Math.Pow(esq, 2) / 4 + 15 * Math.Pow(esq, 3) / 128);
    double A4 = 15 * (Math.Pow(esq, 2) + 3 * Math.Pow(esq, 3) / 4) / 256;
    double A6 = 35 * Math.Pow(esq, 3) / 3072;

    double Nprime = N - Nzero;
    double mprime = Nprime / kzero;
    double smn = (a - b) / (a + b);
    double G = a * (1 - smn) * (1 - Math.Pow(smn, 2)) * (1 + 9 * Math.Pow(smn, 2) / 4 + 225 * Math.Pow(smn, 4) / 64) * Math.PI/ 180.0;
    double sigma = mprime * Math.PI / (180 * G);
    double phiprime = sigma + (3 * smn / 2 - 27 * Math.Pow(smn, 3) / 32) * Math.Sin(2 * sigma) + (21 * Math.Pow(smn, 2) / 16 - 55 * Math.Pow(smn, 4) / 32) * Math.Sin(4 * sigma) + (151 * Math.Pow(smn, 3) / 96) * Math.Sin(6 * sigma) + (1097 * Math.Pow(smn, 4) / 512) *Math.Sin(8 * sigma);
    double rhoprime = a * (1 - esq) / Math.Pow((1 - esq * Math.Pow((Math.Sin(phiprime)), 2)), 1.5);
    double upsilonprime = a / Math.Sqrt(1 - esq * Math.Pow((Math.Sin(phiprime)), 2));

    double psiprime = upsilonprime / rhoprime;
    double tprime = Math.Tan(phiprime);
    double Eprime = E - Ezero;
    double chi = Eprime / (kzero * upsilonprime);
    double term_1 = tprime * Eprime * chi / (kzero * rhoprime * 2);
    double term_2 = term_1 * Math.Pow(chi, 2) / 12 * (-4 * Math.Pow(psiprime, 2) + 9 * psiprime * (1 - Math.Pow(tprime, 2)) + 12 * Math.Pow(tprime, 2));
    double term_3 = tprime * Eprime * Math.Pow(chi, 5) / (kzero * rhoprime * 720) * (8 * Math.Pow(psiprime, 4) * (11 - 24 * Math.Pow(tprime, 2)) - 12 * Math.Pow(psiprime, 3) * (21 - 71 * Math.Pow(tprime, 2)) + 15 * Math.Pow(psiprime, 2) * (15 - 98 * Math.Pow(tprime, 2) + 15 * Math.Pow(tprime, 4)) + 180 * psiprime * (5 * Math.Pow(tprime, 2) - 3 * Math.Pow(tprime, 4)) + 360 * Math.Pow(tprime, 4));
    double term_4 = tprime * Eprime * Math.Pow(chi ,7) / (kzero * rhoprime * 40320) * (1385 + 3633 * Math.Pow(tprime, 2) + 4095 * Math.Pow(tprime, 4) + 1575 * Math.Pow(tprime, 6));
    double term1 = chi * (1 / Math.Cos(phiprime));
    double term2 = Math.Pow(chi, 3) * (1 / Math.Cos(phiprime)) / 6 * (psiprime + 2 * Math.Pow(tprime, 2));
    double term3 = Math.Pow(chi, 5) * (1 / Math.Cos(phiprime)) / 120 * (-4 * Math.Pow(psiprime, 3) * (1 - 6 * Math.Pow(tprime, 2)) + Math.Pow(psiprime, 2) * (9 - 68 * Math.Pow(tprime, 2)) + 72 * psiprime * Math.Pow(tprime, 2) + 24 * Math.Pow(tprime, 4));
    double term4 = Math.Pow(chi, 7) * (1 / Math.Cos(phiprime)) / 5040 * (61 + 662 * Math.Pow(tprime, 22) + 1320 * Math.Pow(tprime, 4) + 720 * Math.Pow(tprime, 6));

    double latitude = (phiprime - term_1 + term_2 - term_3 + term_4) * 180 / Math.PI;
    double longitude = lambdazero + 180 / Math.PI * (term1 - term2 + term3 - term4);

    Console.WriteLine("Lat/Long: " + latitude.ToString() + ',' + longitude.ToString());
    Console.ReadLine();
}

I've just done something similar.

  The Formula for the conversion is provided here by LINZ.

We implemented this first in Excel, and then SQL. We have shared my SQL code in this post. It may be easier for you to read/transform.

I've just done something similar in SQL. The Formula for the conversion is provided here by LINZ.

We implemented this first in Excel, and then SQL. We have shared my SQL code in this post.

Edit: I got bored and had a play. Here you go.This works.

static void Main(string[] args)
{
    //Common variables            
    double a       = 6378137;
    double f       = 1 / 298.257222101;
    double phizero  = 0;
    double lambdazero  = 173;
    double Nzero   = 10000000;
    double Ezero   = 1600000;
    double kzero   = 0.9996;            

    //input Northing(Y); Easting(X) variables
    double N       = 5427502.0;
    double E       = 1749165.0;
    
    //Calculation: From NZTM to lat/Long

    double b = a * (1 - f);
    double esq = 2 * f - Math.Pow(f, 2);
    double Z0 = 1 - esq / 4 - 3 * Math.Pow(esq, 2) / 64 - 5 * Math.Pow(esq, 3) / 256;
    double A2 = 0.375 * (esq + Math.Pow(esq, 2) / 4 + 15 * Math.Pow(esq, 3) / 128);
    double A4 = 15 * (Math.Pow(esq, 2) + 3 * Math.Pow(esq, 3) / 4) / 256;
    double A6 = 35 * Math.Pow(esq, 3) / 3072;

    double Nprime = N - Nzero;
    double mprime = Nprime / kzero;
    double smn = (a - b) / (a + b);
    double G = a * (1 - smn) * (1 - Math.Pow(smn, 2)) * (1 + 9 * Math.Pow(smn, 2) / 4 + 225 * Math.Pow(smn, 4) / 64) * Math.PI/ 180.0;
    double sigma = mprime * Math.PI / (180 * G);
    double phiprime = sigma + (3 * smn / 2 - 27 * Math.Pow(smn, 3) / 32) * Math.Sin(2 * sigma) + (21 * Math.Pow(smn, 2) / 16 - 55 * Math.Pow(smn, 4) / 32) * Math.Sin(4 * sigma) + (151 * Math.Pow(smn, 3) / 96) * Math.Sin(6 * sigma) + (1097 * Math.Pow(smn, 4) / 512) *Math.Sin(8 * sigma);
    double rhoprime = a * (1 - esq) / Math.Pow((1 - esq * Math.Pow((Math.Sin(phiprime)), 2)), 1.5);
    double upsilonprime = a / Math.Sqrt(1 - esq * Math.Pow((Math.Sin(phiprime)), 2));

    double psiprime = upsilonprime / rhoprime;
    double tprime = Math.Tan(phiprime);
    double Eprime = E - Ezero;
    double chi = Eprime / (kzero * upsilonprime);
    double term_1 = tprime * Eprime * chi / (kzero * rhoprime * 2);
    double term_2 = term_1 * Math.Pow(chi, 2) / 12 * (-4 * Math.Pow(psiprime, 2) + 9 * psiprime * (1 - Math.Pow(tprime, 2)) + 12 * Math.Pow(tprime, 2));
    double term_3 = tprime * Eprime * Math.Pow(chi, 5) / (kzero * rhoprime * 720) * (8 * Math.Pow(psiprime, 4) * (11 - 24 * Math.Pow(tprime, 2)) - 12 * Math.Pow(psiprime, 3) * (21 - 71 * Math.Pow(tprime, 2)) + 15 * Math.Pow(psiprime, 2) * (15 - 98 * Math.Pow(tprime, 2) + 15 * Math.Pow(tprime, 4)) + 180 * psiprime * (5 * Math.Pow(tprime, 2) - 3 * Math.Pow(tprime, 4)) + 360 * Math.Pow(tprime, 4));
    double term_4 = tprime * Eprime * Math.Pow(chi ,7) / (kzero * rhoprime * 40320) * (1385 + 3633 * Math.Pow(tprime, 2) + 4095 * Math.Pow(tprime, 4) + 1575 * Math.Pow(tprime, 6));
    double term1 = chi * (1 / Math.Cos(phiprime));
    double term2 = Math.Pow(chi, 3) * (1 / Math.Cos(phiprime)) / 6 * (psiprime + 2 * Math.Pow(tprime, 2));
    double term3 = Math.Pow(chi, 5) * (1 / Math.Cos(phiprime)) / 120 * (-4 * Math.Pow(psiprime, 3) * (1 - 6 * Math.Pow(tprime, 2)) + Math.Pow(psiprime, 2) * (9 - 68 * Math.Pow(tprime, 2)) + 72 * psiprime * Math.Pow(tprime, 2) + 24 * Math.Pow(tprime, 4));
    double term4 = Math.Pow(chi, 7) * (1 / Math.Cos(phiprime)) / 5040 * (61 + 662 * Math.Pow(tprime, 22) + 1320 * Math.Pow(tprime, 4) + 720 * Math.Pow(tprime, 6));

    double latitude = (phiprime - term_1 + term_2 - term_3 + term_4) * 180 / Math.PI;
    double longitude = lambdazero + 180 / Math.PI * (term1 - term2 + term3 - term4);

    Console.WriteLine("Lat/Long: " + latitude.ToString() + ',' + longitude.ToString());
    Console.ReadLine();
}
Source Link

I've just done something similar.

The Formula for the conversion is provided here by LINZ.

We implemented this first in Excel, and then SQL. We have shared my SQL code in this post. It may be easier for you to read/transform.