I started with a binary file that had elevation data and following details:
GENEARAL INFORMATION ABOOUT THE DATASETS
nx=42600
ny=39600
resolution=0.000833
lonmin=64.500000000
lonmax=100.000000000
latmin=5.000000000
latmax=38.000000000
I read the binary file into an array and reshaped it using (nx, ny) as follows::
type here
data_array = data_array.reshape((ny, nx))
Now since this array values correspond to an elevation of a sutiable grid size that I have mentioned above, I tried creating a lat and lon named array and finally making a .nc file in this manner.
lon = np.linspace(lonmin, lonmax, nx)
lat = np.linspace(latmin, latmax, ny)
import xarray as xr
ds = xr.Dataset(
{
"data": (["lat", "lon"], data_array),
},
coords={"lon": lon, "lat": lat}
)
ds.to_netcdf("merit_elevtn.nc")
When I try to plot my data from this file, created I get the following plot::
As you can see rather than the lat and lon nx and ny are in the plot. Am I doing something wrong here ?
Please let me know if is there any error in my way of assigning latitude and longitude co-ordinates to this array or is there any better way to do this. Also I downloaded this file and tried to work it out with QGIS but found that the file is being plotted in this way enter image description here
Also If I am trying now to clip the file for specifc latitude and longitudes, the clipped file does not match the required topography.