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.
Best Answer
EDITED after feedback from question poster.
Step 1: if files are not georeferenced, try the methods described here, Georeferencing using GDAL?. Also world files could work for weither png or tif (http://en.wikipedia.org/wiki/World_file; http://www.gdal.org/gdal_translate.html).
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 waygdalwarp -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: http://www.gdal.org/gdalwarp.html
hope this helps :)