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 1000 polygons in my shapefile. I also have 1000 PNG files. Do you think it is possible (based on a common attribute), through a script or something, to assign each of those PNG files to a polygon? I am looking for an automated process which should "read" the polygon coordinates and based on that common attribute, it should somehow take the corresponding PNG, transform it in a tiff file and place it between the boundaries of that polygon? Basically, do the georeferencing for me ...

I use mostly open source software and Global Mapper but I have no clue on how to do this..

Many thanks for the support,

share|improve this question
Even if your polygon has same aspect ratio as the corresponding image, how will you assure its rotation won't be off by 180 degrees? – Kirk Kuykendall Dec 16 '11 at 22:32
Hello Kirk, My desire is to stretch the png to the bounds of the polygon so it would fit exactly within the bounds. If it rotates the image 180 degrees, well, that is no problem. I just want to find a way to replace the manual geoeferencing of 1000 images in order to speed up the process. Honestly, I do not know how to do this..I appreciate any advice – Robert Dec 17 '11 at 8:41
When you are manually doing this, how do you verify that the image's rotation isn't off by 180 degrees? – Kirk Kuykendall Dec 17 '11 at 16:11
If the polygons have the name of the PNG file as attribute, some script lines should do the job (GRASS or GDAL). Otherwise, how to related polygons and PNG positions to each other? – markusN Dec 18 '11 at 8:11
Just as I thought, problem is with vertex order. There is not rule, for example, I can not say that every first vertex of every polygon is always lower left corner of png image or any other similar rule. That complicates things. It could probably be done with python and GDAL/OGR but you would need lot of IF's or you could calculate centroid of that polygon and assign rotation angle to that centroid and then somehow calculate image rotation and position based on that centroid. That is just a quick thought. – Mario Miler Dec 19 '11 at 19:43

I recommend using Python to script a solution. I'd try to georeference the png corners to the corresponding polygon envelope or bounding rectangle corners. This can be accomplished with gdal_translate -gcp and gdal_warp. The resulting shape image in the geotiff may not perfectly overlay the polygon shape, but should be close.

share|improve this answer
@Kirk Kuykendall: Well, the image is a label (let's say, it contains the word GEO on a blue background), if I manually assign the coordinates for 4 points (the corners of the image) I know exactely how it is going to show up on my map because I already have the polygon from where I took the coordinates and it will fit right inside. Does this make sense, am I missing something in your question? Sorry if yes, @ klewis Thank you very much, I will try this, maybe something good happens :) – Robert Dec 17 '11 at 17:17

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.