I just took the lat_lon example and adapted it to the case where the 1D dimensions are not lat/lon but x/y and we provide a grid_mapping to describe the crs.
note: I failed to generate .nc file because ncgen failed with:
>> ncgen -o example1_compact.nc example1_compact.cdlInput file contains a BOM indicating a non-UTF8 encoding
I just took the lat_lon example and adapted it to the case where the 1D dimensions are not lat/lon but x/y and we provide a grid_mapping to describe the crs.