[ncl-talk] Projection lat/lon (follow-up to earlier GeoTIFF to netcdf email)

Rick Brownrigg brownrig at ucar.edu
Thu Mar 1 13:37:47 MST 2018


Hi Michael,

NCL has an unadvertised interface to the Proj4 cartographic library, which
could be used to convert between the implied meters coordinate system of
the projection into lat/lons. All the info is there in the metadata needed
to make this possible.

The function is TransformCoordinate_W(SrcProj:string, DstProj:string,
x:double, y:double, z:double)

where Src/DstProj are proj4 projection parameters. Coordinates are passed
in and returned via the x/y/z arrays.

If you are not familiar with Proj4, if you could share this NetCDF file
with me, I'll take a stab at an implementation showing the steps, and
repost the solution back to you and as well as the email group. Besides
that, the original tiff appears to contain multiple subsampled images of
the original -- I'm curious as to what GDAL did with that.

That all said, I'm traveling the next 4 days, and may not be able to get to
this right away.

FWIW...
Rick


On Thu, Mar 1, 2018 at 9:29 AM, Michael Notaro <mnotaro at wisc.edu> wrote:

> Thanks to Jonathan's suggestion, I used GDAS to convert a GeoTIFF file
> containing slope data to netcdf.
>
> The netcdf file contains Band1(y,x) where y=8732 and x=10405.  The
> projection is Lambert_Conformal_Conic_2SP.
>
> See the info below on the projection.  How can I obtain the latitude and
> longitude
>
> values for each grid cell?
>
>
> Thanks, Michael
>
>
>
> NCDUMP RESULTS
>
>
> [mmia:~/nps_daymet/slope_ncols_nrows_rescale_flip_shift.tif] notaro%
> ncdump -h slope_daymet.nc
>
> netcdf slope_daymet {
>
> dimensions:
>
> x = 10405 ;
>
> y = 8732 ;
>
> variables:
>
> char lambert_conformal_conic ;
>
> lambert_conformal_conic:grid_mapping_name = "lambert_conformal_conic" ;
>
> lambert_conformal_conic:longitude_of_central_meridian = -100. ;
>
> lambert_conformal_conic:false_easting = 0. ;
>
> lambert_conformal_conic:false_northing = 0. ;
>
> lambert_conformal_conic:latitude_of_projection_origin = 42.5 ;
>
> lambert_conformal_conic:standard_parallel = 25., 60. ;
>
> lambert_conformal_conic:long_name = "CRS definition" ;
>
> lambert_conformal_conic:longitude_of_prime_meridian = 0. ;
>
> lambert_conformal_conic:semi_major_axis = 6378137. ;
>
> lambert_conformal_conic:inverse_flattening = 298.257223563 ;
>
> lambert_conformal_conic:spatial_ref = "PROJCS[\"Lambert_Conformal_Conic_2SP\",GEOGCS[\"WGS
> 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,
> AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],
> PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],
> AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],
> PARAMETER[\"standard_parallel_1\",25],PARAMETER[\"standard_
> parallel_2\",60],PARAMETER[\"latitude_of_origin\",42.5],
> PARAMETER[\"central_meridian\",-100],PARAMETER[\"false_
> easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"
> metre\",1,AUTHORITY[\"EPSG\",\"9001\"]]]" ;
>
> lambert_conformal_conic:GeoTransform = "-5813750 1000 0 4995500 0 -1000 "
> ;
>
> double x(x) ;
>
> x:standard_name = "projection_x_coordinate" ;
>
> x:long_name = "x coordinate of projection" ;
>
> x:units = "m" ;
>
> double y(y) ;
>
> y:standard_name = "projection_y_coordinate" ;
>
> y:long_name = "y coordinate of projection" ;
>
> y:units = "m" ;
>
> float Band1(y, x) ;
>
> Band1:long_name = "GDAL Band Number 1" ;
>
> Band1:_FillValue = -9999.f ;
>
> Band1:SourceBandIndex = 0 ;
>
> Band1:grid_mapping = "lambert_conformal_conic" ;
>
>
> // global attributes:
>
> :GDAL_AREA_OR_POINT = "Area" ;
>
> :GDAL_DataType = "Generic" ;
>
> :Conventions = "CF-1.5" ;
>
> :GDAL = "GDAL 2.2.3, released 2017/11/20" ;
>
> :history = "Thu Mar 01 10:05:20 2018: GDAL CreateCopy( slope_daymet.nc,
> ... )" ;
>
>
> INFO FROM GDAL
>
>
> [mmia:~/nps_daymet/slope_ncols_nrows_rescale_flip_shift.tif] notaro%
> gdalinfo slope_ncols_nrows_rescale_flip_shift.tif
>
> Driver: GTiff/GeoTIFF
>
> Files: slope_ncols_nrows_rescale_flip_shift.tif
>
>        slope_ncols_nrows_rescale_flip_shift.tif.ovr
>
>        slope_ncols_nrows_rescale_flip_shift.tif.aux.xml
>
> Size is 10405, 8732
>
> Coordinate System is:
>
> PROJCS["Lambert_Conformal_Conic_2SP",
>
>     GEOGCS["WGS 84",
>
>         DATUM["WGS_1984",
>
>             SPHEROID["WGS 84",6378137,298.257223563,
>
>                 AUTHORITY["EPSG","7030"]],
>
>             AUTHORITY["EPSG","6326"]],
>
>         PRIMEM["Greenwich",0],
>
>         UNIT["degree",0.0174532925199433],
>
>         AUTHORITY["EPSG","4326"]],
>
>     PROJECTION["Lambert_Conformal_Conic_2SP"],
>
>     PARAMETER["standard_parallel_1",25],
>
>     PARAMETER["standard_parallel_2",60],
>
>     PARAMETER["latitude_of_origin",42.5],
>
>     PARAMETER["central_meridian",-100],
>
>     PARAMETER["false_easting",0],
>
>     PARAMETER["false_northing",0],
>
>     UNIT["metre",1,
>
>         AUTHORITY["EPSG","9001"]]]
>
> Origin = (-5813750.000000000000000,4995500.000000000000000)
>
> Pixel Size = (1000.000000000000000,-1000.000000000000000)
>
> Metadata:
>
>   AREA_OR_POINT=Area
>
>   DataType=Generic
>
> Image Structure Metadata:
>
>   COMPRESSION=LZW
>
>   INTERLEAVE=BAND
>
> Corner Coordinates:
>
> Upper Left  (-5813750.000, 4995500.000) (150d36'29.26"E, 47d26' 3.93"N)
>
> Lower Left  (-5813750.000,-3736500.000) (142d57' 5.67"W,  2d31'41.12"S)
>
> Upper Right ( 4591250.000, 4995500.000) (  3d59'18.41"E, 58d17'42.04"N)
>
> Lower Right ( 4591250.000,-3736500.000) ( 64d56'47.60"W,  1d29'22.14"N)
>
> Center      ( -611250.000,  629500.000) (108d35'55.06"W, 48d 8'15.05"N)
>
> Band 1 Block=128x128 Type=Float32, ColorInterp=Gray
>
>   Min=0.000 Max=0.822
>
>   Minimum=0.000, Maximum=0.822, Mean=0.008, StdDev=0.030
>
>   NoData Value=-9999
>
>   Overviews: 5203x4366, 2602x2183, 1301x1092, 651x546, 326x273, 163x137
>
>   Metadata:
>
>     SourceBandIndex=0
>
>     STATISTICS_COVARIANCES=0.0009288078976163249
>
>     STATISTICS_MAXIMUM=0.82241380214691
>
>     STATISTICS_MEAN=0.0081764099199458
>
>     STATISTICS_MINIMUM=0
>
>     STATISTICS_SKIPFACTORX=1
>
>     STATISTICS_SKIPFACTORY=1
>
>     STATISTICS_STDDEV=0.030476349807947
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180301/19ee344e/attachment.html>


More information about the ncl-talk mailing list