3

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,

8
  • 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? Dec 16, 2011 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, 2011 at 8:41
  • 1
    When you are manually doing this, how do you verify that the image's rotation isn't off by 180 degrees? Dec 17, 2011 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, 2011 at 8:11
  • 1
    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. Dec 19, 2011 at 19:43

1 Answer 1

1

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.

1
  • @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, 2011 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.