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

1 Answer 1

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 (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 :)

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

 
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.