Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 4096x4096 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 4096x4096 as it actually creates a better image than if not. Meaning, if I leave the image in it's native size, 1440x720 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 1536x768 the gap shows up to the right of the 0 meridian. If I scale to 1280x640 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.

share|improve this question
    
Something's gotta give when you convert an image with aspect ratio 1:2 into one with aspect ratio 1:1: either clipping occurs, you get blank borders to fill empty space, or you need a 2:1 stretch. –  whuber Apr 20 '11 at 21:28
    
I've run the same processes over one of the files from the FTP site you provided, and I have an image that fits its bounds properly. Can you provide a screenshot of the effect you're getting? Does the effect happen after the gdaldem step, or the convert step? –  MerseyViking Apr 20 '11 at 21:40
    
Ah yes, as whuber says, your aspect ratio is wrong if you use the parameters you provided in the text, but the commandline parameters, which are the ones I used, have the correct aspect ratio. –  MerseyViking Apr 20 '11 at 21:42
    
Having said that, I've just tried creating it as a 4096 x 4096 and QGIS loads it up with no problem. Additionally, loading both versions into GIMP shows a map that goes right up to the left and right edges. –  MerseyViking Apr 20 '11 at 21:49
    
@whuper - Absolutely, I completely agree. I realize that trying to make a 1:2 dataset into a 1:1 image, you are almost invalidating the data. Having said that, my expectations were to get output that is essentially a 2:1 stretch, rather than empty space. I'm at the mercy of the business requirements set before me :( Oh the things we will do for a pretty picture. @MerseyViking - Interesting, let me get back to you on that. I'm not the primary one working on this and so I need to get their input. Thanks for the feedback though. –  malonso Apr 21 '11 at 11:00

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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