[GIS] How to create a 4096×4096 png from a 1440×720 data set using GDAL

gdalgoogle mapsnetcdf

I'm having a bear of a time trying to do something that seems fairly straightforward. I'm trying to take a netcdf file from ftp://eclipse.ncdc.noaa.gov/pub/OI-daily-v2/NetCDF/2011/AVHRR-AMSR/ and turn it into a 4096×4096 png so that I can tile it up for use w/google maps. I've been using the following commands but it always seems to create blank areas on the east and west borders:

/usr/local/bin/gdal_translate -a_srs EPSG:4326 -outsize 4096 4096 -a_ullr 0 90 360 -90 NETCDF:"input.nc":sst -of netCDF output.nc
/usr/local/bin/gdaldem color-relief output.nc -b 1 -alpha colorscale.txt -of PNG output.png
/usr/bin/convert output.png -transparent #FFFFFF output.png

Am I just approaching this the wrong way? Am I using the wrong tools?

FWIW – gdal_translate is v1.8.0

Thanks in advance.

UPDATE: "Answer" below from Dija – colleague of mine – is actually a response to the comments on the question itself.

UPDATE Accidentally added an answer instead of a comment. Moving it here.

I thought I'd weigh in here. I've been working on this issue for a little while now. I've tried many iterations of the process. I scaled these images to the 4096×4096 as it actually creates a better image than if not. Meaning, if I leave the image in it's native size, 1440×720 I get a larger gap at the prime meridian (for this data set) and at the 180th meridian for other data sets. I scaled the output image to be a multiple of 256 (to fit better with google) and get various results.

If I scale it to 1536×768 the gap shows up to the right of the 0 meridian. If I scale to 1280×640 it's to the left. If I leave it alone, it's pretty much splits it.

I have taken the base image that gdaldem spits out, cut it in half and matched the edges up…they line up perfectly. This leads me to think that there's something weird going on with gdal2tiles.py

I wrote my own tiler that I'm getting ready to turn loose on our images to see if the gap remains.

I'll put together some screen shots to show what I am talking about with how the gap as well as report on what my tiler does.

Thanks for any input you might have. It's appreciated.

UPDATE 2 I ran the maptiler I wrote against the original raster and it works fine with out a gap. gdal2tiles.py seems to be the problem. It introduces a transparent edge to the last tile that touches the 180th meridian.

Best Answer

gdal_grid has parameters that let you designate the extent coordinates of your output raster.

gdal_grid -txe [xcoord1] [xcoord2] -tye [ycoord1] [ycoord2]

where the lower left coordinate would be (xcoord1,ycoord1) and the upper right would be (xcoord2,ycoord2)

GDAL will interpolate your data according to your output extents

Related Question