3

I am using gdal_translate to extract a NetCDF out to tiff. In the gdal_translate documentation, there is an option -a_ullr to define the upper-left and lower-right corners (bounds) of the grid. Are these the cell centers of those grid cells, or the outer edges of the grid itself?

  • 2
    I don't know, but you could quickly test this by running it and checking in a GIS program. My guess is that it's the absolute bounds, not pixel centers, but that's just a guess. – Jon Mar 7 '18 at 4:41
2

I like the suggestion by @Jon. Let's give it a try.

  • Sample: A single cell, 1000m x 1000m, centered at (0, 0)

This cell is shown as green (value 200) on Dummy1x1_BYTE layer.

enter image description here

  • gdal_translate -a_ullr 0 0 1000 -1000 returned an orange cell on a new layer Dummy1x1_BYTE_ullr.

This orange cell is set to Upper Left = (0, 0) and Lower Right (1000, -1000).

As @Jon has said. Yes, -a_ullr sets coordinates of corner points.

1

Per Jon's suggestion, I tried something similar to Kazuhito. Here was my NetCDF input:

NC_GLOBAL#XORIG=-130
NC_GLOBAL#YORIG=22.5
NC_GLOBAL#XCELL=0.03999999910593033
NC_GLOBAL#YCELL=0.03999999910593033
NC_GLOBAL#NCOLS=1751
NC_GLOBAL#NROWS=751

I calculated the Max X/Y values as such:

max lon: -130 + (0.03999999910593033 * 1751) = -59.96000156551599217
max lat: 22.5 + (0.03999999910593033 * 751) = 52.53999932855367783

I used gdal_translate to move from NetCDF to Tiff using this switch:

-a_ullr -130 52.53999932855367783 -59.96000156551599217 22.5

Then, I zoomed way in and dropped some point markers on top of the raster:

The lower left

The upper right

The rasters are mostly a background value of 0, drawn as black in those screenshots. The labeled points come out right on the corners of the raster, so it appears the GDAL's -a_ullr option is using the outer boundaries of the grid, and not cell centers.

Also, I should note that the cell size is unchanged out to 17 significant digits (decimal degrees), so assuming the cell size is the extent divided by the number of rows/columns, then the output is true to the input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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