Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have one .PNG basemap with known North edge of Latitude = 52.48, a South edge of Latitude = 21.94, an east edge of Longitude = -61.87 and a west edge of Longitude = -129.37.

And I have another PNG image overlay with a known North edge of Latitude = 50.03, a South edge of Latitude = 22.02, an east edge of Longitude = -67.24 and a west edge of Longitude = -124.99.

Is there a way using GDAL or other simple scripting tools to process the second PNG image to be in an output that directly overlays (same x/y dimensions) the basemap?

I have no trouble generating map tiles that overlay each other beautifully - but I seem to be having no luck figuring out the syntax of the seemingly simpler case.

Help in the form of a simple example is much appreciated!

To be clear: the goal is an output .png file that has the exact same x/y dimensions as the basemap, and which can directly overlay on top of it.

share|improve this question
up vote 1 down vote accepted

EDITED after feedback from question poster.

Step 1: if files are not georeferenced, try the methods described here, georeferencing using gdal tools. Also world files could work for weither png or tif (;

Step 2: two methods could work for the clipping. Trying gdaltranslate with the following option -projwin ulx uly lrx lry: would work if you have the coordinates as the question seems to imply.

OR, you have the option of using gdaltindex newclip.shp basemap.png to create a clip shapefile. The shapefile can be used in the following way

gdalwarp -cutline /path/to/newclip.shp -crop-to-cutline oldimage.tif newimage.tif

remember that the path I show is for linux. Windows would be C:\something\clip.shp. Also, the example does not account for CRS. There is the option of replacing the cutline with -te xmin ymin xmax ymax

helpful link:

hope this helps :)

share|improve this answer
Perhaps the part I am missing is that all I have is a plain .png file and the edge coordinates - the file is not a TIF with this information embedded, and gdalwarp doesn't know where to begin. – radven Oct 4 '12 at 23:32
So you need to georeference the file as well? hmmm I'll get back to you. – s_a Oct 4 '12 at 23:44
I think I am georeferencing the maps fine now, and turning them into GTiff's. But... I am not sure I am any closer to the goal of getting an output .png that has the same x/y dimensions as the basemap, and can directly overlay. – radven Oct 5 '12 at 1:04
I was using the -te option, but now that I have converted the basemap into a GTiff (and confirmed the details via gdalinfo) I have tried the -crop_to_cutline option you described, and it fails without output or error: gdalwarp -cutline ./output43264.tif -crop_to_cutline output4.tif outputN.tif – radven Oct 5 '12 at 1:35
Hi radven, I hope my newest edits are helpful. GOod luck. any questions? just ask :) – s_a Oct 5 '12 at 12:18

Your Answer


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.