0

Based on following information:

Size is 1200, 1400
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG","7030"]],   (i parametri 2 e 3 sono il semiasse maggiore e lo schiacciamento)
            AUTHORITY["EPSG", "6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",42],
    PARAMETER["central_meridian",12.5],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre", 1, AUTHORITY["EPSG", "9001"]]
]
Origin = (-598884.437500000000000, 650790.250000000000000)
Pixel Size = (996.479919433593750,-999.677795410156250)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2018:04:01 00:10:06
  TIFFTAG_DOCUMENTNAME=/datamet/data/tmp/export/RADAR/36/RRN/VMI/VMI.geotif
  TIFFTAG_IMAGEDESCRIPTION=IDL TIFF file
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=IDL 8.3, Exelis Visual Information Solutions, Inc.
  TIFFTAG_XRESOLUTION=100
  TIFFTAG_YRESOLUTION=100
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -598884.438,  650790.250) (  4d32'13.20"E, 47d34'44.14"N)
Lower Left  ( -598884.438, -748758.664) (  5d56'18.16"E, 35d 4'36.70"N)
Upper Right (  596891.466,  650790.250) ( 20d26'12.34"E, 47d34'50.73"N)
Lower Right (  596891.466, -748758.664) ( 19d 2'23.69"E, 35d 4'40.94"N)
Center      (    -996.486,  -48984.207) ( 12d29'17.00"E, 41d33'32.31"N)
Band 1 Block=1200x1 Type=Float32, ColorInterp=Gray

I want to obtain (lon, lat) for each point of grid.

I'm trying with this Java code:

import ucar.unidata.geoloc.EarthEllipsoid;
import ucar.unidata.geoloc.LatLonPoint;
import ucar.unidata.geoloc.LatLonPointImpl;
import ucar.unidata.geoloc.ProjectionImpl;
import ucar.unidata.geoloc.ProjectionPointImpl;
import ucar.unidata.geoloc.projection.TransverseMercator;
import ucar.unidata.geoloc.projection.proj4.TransverseMercatorProjection;

public class TestGeoTiff {
    public static void main (String[] args) {
        //corners of my grid
        test(new double[] { -598884.438,  650790.250});
        test(new double[] { -598884.438, -748758.664});
        test(new double[] {  596891.466,  650790.250});
        test(new double[] {  596891.466, -748758.664});
    }

    public static void test (double[] XYproj) {

        ProjectionImpl proj = new TransverseMercator(42, 12.5, 1., 0., 0.);
        ProjectionPointImpl p   = new ProjectionPointImpl(XYproj[0], XYproj[1]);
        LatLonPointImpl lp      = (LatLonPointImpl) proj.projToLatLon(p);
        System.out.println(lp.getLongitude()+", "+lp.getLatitude());

        //or alternatively
        ProjectionImpl proj2 = new TransverseMercatorProjection(EarthEllipsoid.WGS84, 12.5, 42, 1., 0., 0.);
        ProjectionPointImpl p2  = new ProjectionPointImpl(XYproj[0], XYproj[1]);
        LatLonPointImpl lp2     = (LatLonPointImpl) proj2.projToLatLon(p2);
        System.out.println(lp2.getLongitude()+", "+lp2.getLatitude());
    }
}

The output is:

12.5, 90.0
-77.50000000000001, 1.229040709186457E-39
12.5, -90.0
-77.50000000000001, 9.003088929951159E-40
12.5, 90.0
102.50000000000001, 1.6804171192682352E-39
12.5, -90.0
102.50000000000001, 1.2309555453373566E-39

but it's not what I expected and it's very different from what it should be

Upper Left  ( -598884.438,  650790.250) --> (  4d32'13.20"E, 47d34'44.14"N)
Lower Left  ( -598884.438, -748758.664) --> (  5d56'18.16"E, 35d 4'36.70"N)
Upper Right (  596891.466,  650790.250) --> ( 20d26'12.34"E, 47d34'50.73"N)
Lower Right (  596891.466, -748758.664) --> ( 19d 2'23.69"E, 35d 4'40.94"N)

Is there a solution?

  • Based on the netCDF help, it looks like the 2nd one is more correct (central meridian then latitude of origin order). Try a point at the middle of the data: 0,0 and see what you get. – mkennedy Apr 11 '18 at 19:58
  • test(new double[] {0, 0}); --> 12.5, 42 Sorry, Input coordinates must be expressed in kilometers !!! Output of 2nd one is: 4.537000511170972, 47.57892803859768 5.938377833640201, 35.07686200970762 20.436762469043558, 47.580758246377265 19.039912999843207, 35.078039793078155 It's about what I expect ! – Alessio Frabotta Apr 12 '18 at 11:05
  • I'm glad you have it working! – mkennedy Apr 12 '18 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.