0

I am attempting to convert the MISR_AM1_AS_AEROSOL_*.nc dataset with 4.4 km resolution to GeoTIFF using Python, but the tif generated is not georeferenced (see image below). I don't have much experience with that so is there a way to do that?

fname = "MISR_AM1_AS_AEROSOL_P206_O112235_F13_0023.nc"
f = nc.Dataset(fname)
var = f['/4.4_KM_PRODUCTS/Aerosol_Optical_Depth']

# Read data.
data = var[:]
lat = f['/4.4_KM_PRODUCTS/Latitude'][:]
lon = f['/4.4_KM_PRODUCTS/Longitude'][:]

fillvalue = var.getncattr('_FillValue')
data[data == fillvalue] = np.nan
data = np.ma.masked_array(data, np.isnan(data))

t = rio.transform.from_origin(lon.min(), lat.max(), 0.044, 0.044)

fout="MISR_AM1_AS_AEROSOL_P206_O112235_F13_0023.tif"
ndt=rio.open(fout, 'w',
  driver='GTiff', 
  height=data.shape[0],
  width=data.shape[1],
  count=1,
  dtype=str(data.dtype),
  crs='EPSG:4326',
  transform=t)
ndt.write(data,1)
ndt.close()

Figure georeferenced correctly Result of Figure GEOtiff not georeferenced

1

1 Answer 1

0

I'm thinking it may be easier for you to use the GDAL tools that already exist to do this. You can always call them with python if you have a lot of them you need to extract.

Check out this answer: https://gis.stackexchange.com/a/163993/57277

You can take a look at the GDAL documentation here: https://gdal.org/drivers/raster/netcdf.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.