2

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.

1

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 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: http://www.gdal.org/gdalwarp.html

hope this helps :)

7
  • 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 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.