[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #MTH-829107]: Geotiff to NetCDF



Ok, Here is standard way to do this.

I assume that you have an evenly spaced coordinates in
both the lat and lon directions.

First, we define what is called coordinate variables
that map a lat value to an index
and a lon value to an index.
-------------
netcdf Geotiff {
dimensions:
    time=UNLIMITED;
    rgb = 3;
    lon = 4886;
    lat = 5462;
variables:
    float lat(lat);
    float lon(lon);
    float image(time, lon, lat, rgb);
}
---------- 
The idea is that we can use the lat and lon variables to convert
an index to a set of (LAT,LON) coordinates by using the (x,y) such that
lat(x) == LAT and lon(y) == LON.
We then store the image in image(T,x,y,RGB) where T and RGB
are the appropriate time and rgb values.

This may be confusing, so I would suggest you google
"netcdf coordinate variables" and see if you can find a
better description.


> Exactly, they are defined as degree.
> I know how to represent lon/lat and time.
> lono = ncf.createVariable("lon", "f4", ("lon",), zlib = True)
> lono.axis = 'X'
> lono.units = "degrees_east"
> lono.long_name = "longitude"
> lono.standard_name = "longitude"
> lono[:] = lon
> print(lono[:])
> 
> lato = ncf.createVariable("lat", "f4", ("lat",), zlib = True)
> lato.axis = 'Y'
> lato.units = "degrees_north"
> lato.long_name = "latitude"
> lato.standard_name = "latitude"
> lato[:] = lat
> print(lato[:])
> 
> time = ncf.createVariable("time", "i4", ("time",), zlib = True)
> time.axis = 'T'
> time.units = "month"
> time.long_name = "time"
> time.standard_name = "time"
> time[:] = 0
> 
> But I don't know how to represent RGB in axis z, and join them with 
> correspondent lon/lat and create image(time,lon,lat,rgb)
> 
> zo = ncf.createVariable("levels", "f4", ("z",), zlib = True)
> zo.axis = 'Z'
> zo.units = "rgb"
> zo.long_name = "3 bands as an RGB image"
> zo.standard_name = "RGB"
> 
> var = ncf.createVariable('image','f4', ('time','lon','lat','z'), zlib=True, 
> fill_value = -9999)
> var.units = "shape"
> var.long_name = "shape entire geotiff"
> var.standard_name = "shape"
> 
> 
> 
> 
> ________________________________
> De: Unidata netCDF Support <address@hidden>
> Enviado: terça-feira, 11 de setembro de 2018 11:00
> Para: address@hidden
> Cc: address@hidden
> Assunto: [netCDF #MTH-829107]: Geotiff to NetCDF
> 
> Ok, then I would define the netcdf metadata as you did, namely:
> -------------
> netcdf Geotiff {
> dimensions:
> time=UNLIMITED;
> rgb = 3;
> lon = 4886;
> lat = 5462;
> variables:
> image(time,lon, lat, rgb);
> }
> -----------
> Is the problem that the values of lat and lon in Geotiff defined
> as degrees (are they?).
> 
> > time shoud be a variable to store the date when the netCDF is created, at 
> > the beginning I used None, but in fact it is not important for me, not at 
> > the moment. I used None, for now, becouse I just need to save a Netcdf with 
> > the format (time,lon,lat,rgb). What it is important to me is save RGB value 
> > correspondent to a lon/lat. I am using netcdf4/python.
> >
> > Regards,
> > Rosana
> > ________________________________
> > De: Unidata netCDF Support <address@hidden>
> > Enviado: terça-feira, 11 de setembro de 2018 10:13
> > Para: address@hidden
> > Cc: address@hidden
> > Assunto: [netCDF #MTH-829107]: Geotiff to NetCDF
> >
> > I am going to need some more info.
> > First, what is the meaning of None in time = None?
> >
> > > Full Name: Rosana Ribeiro
> > > Email Address: address@hidden
> > > Organization: ufba
> > > Package Version:
> > > Operating System:
> > > Hardware:
> > > Description of problem: I have tried to convert a Geotiff into a NetCDF 
> > > and I need to define variables as:
> > > dimensions:
> > > time = None;
> > > rgb = 3;
> > > lon = 4886;
> > > lat = 5462;
> > > variables:
> > > image(time,lon, lat, rgb);
> > > I am having difficult to define a rgb value to a correspondent lon/lat 
> > > values in Netcdf format. How can I do this?
> > >
> > >
> >
> > =Dennis Heimbigner
> > Unidata
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: MTH-829107
> > Department: Support netCDF
> > Priority: Normal
> > Status: Open
> > ===================
> > NOTE: All email exchanges with Unidata User Support are recorded in the 
> > Unidata inquiry tracking system and then made publicly available through 
> > the web.  If you do not want to have your interactions made available in 
> > this way, you must let us know in each email you send to us.
> >
> >
> >
> >
> 
> =Dennis Heimbigner
> Unidata
> 
> 
> Ticket Details
> ===================
> Ticket ID: MTH-829107
> Department: Support netCDF
> Priority: Normal
> Status: Open
> ===================
> NOTE: All email exchanges with Unidata User Support are recorded in the 
> Unidata inquiry tracking system and then made publicly available through the 
> web.  If you do not want to have your interactions made available in this 
> way, you must let us know in each email you send to us.
> 
> 
> 
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: MTH-829107
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.