[GIS] Georeferencing png using gdal

csvgdalgdalwarpgeoreferencingkml

I have created my own fantasy map, I have the map in a full size png and the map broken down into tiles ( with no geo data )

I installed MS4W and tried to use it to get the georeference data put is seems the program got stuck while trying to do the 4th step here

this is my info I got from the 3rd step:

-Size is 4961, 3231

-Coordinate System is `'

  • Image Structure Metadata:
    -INTERLEAVE=PIXEL
  • Corner Coordinates:
  • 1st corner Upper Left( 0.0, 0.0 )
  • 2nd corner Lower Left ( 0.0, 3231.0 )
  • 3rd corner Upper Right ( 4961.0, 0.0 )
  • 4th corner Lower Right ( 4961.0, 3231.0 )
  • Center ( 2480.5, 1615.5 )
  • Band 1 Block=4961×1 Type=UInt16, ColorInterp=Red
  • Band 2 Block=4961×1 Type=UInt16, ColorInterp=Green
  • Band 3 Block=4961×1 Type=UInt16, ColorInterp=Blue
  • Band 4 Block=4961×1 Type=UInt16, ColorInterp=Alpha

4th step said something about -gcp not available or something

Could someone get my png georeferenced and into a kml or csv file for me so that I can continue my project, or help me with using the right code to continue on

here is my map png

Best Answer

Here's a world file for you (as per Gene's suggestion). Cut and paste the following into a text editor and name the file the same as your full-sized map but give it the extension '.pgw' instead on '.png':

1.0
0.0
0.0
-1.0
0.0
3231.0

I've made the following assumptions:

  1. Your map has a resolution (pixel size) of 1m square (i.e. each pixel is a reasonable stride length for a fantasy game humanoid character). If I am wrong, edit lines 1 and 4 accordingly.
  2. I have assumed that your map is not rotated.
  3. I have assumed that your LL corner is at 0,0 in your world. If your pixel size is bigger than 1m square then you will need to multiply your Y coordinate (3231.0) accordingly.
  4. Technically the UL coordinate (last two lines) is the center of your pixel. I have been lazy and set it to the corner. This in theory means that your coordinates would be consistently half a meter out but it's a fantasy world so nobody will know; it is consistent so won't screw up any distant calculations; and it saves a negative value as one of your origin coordinates. Adjust if you are sufficiently worried :)

I would then re-tile your map from the georeferenced full-sized one (this saves you making a world file for each tile)

Now, if you load your fantasy map into a GIS or similar system, you will probably be asked for the Spatial Reference System (SRS). The World file doesn't encapsulate that. It just locates and orients the image file in space relative to a nominal 0,0 origin. Since this is a fantasy map, all you need to do is pretend that it is in the real world somewhere and pick any coordinate system that gives you a flat projection with units in meters (or feet if you prefer but you will may have to adjust the values for resolution in the world file). A couple of suggestions for SRS could be:

  • EPSG: 3857 (aka 900913)
  • EPSG: 27700 (UK National Grid - the advantage of a national grid system UK or otherwise, is that you mostly stay clear of the poles and the international dateline and can hopefully avoid any weirdness which may result from such a location)

Your choice might not matter at all... on the other hand, you choice of SRS might be influenced by what you intend to do with your KML/CSV file (like you might be making a game with a post-apocalyptic theme but set in Quebec ...with zombies...). If you are using Google Earth or similar as a 'platform' for your game/fantasy world, so long as all your other data are in the same coordinate system, all should be well.

However, I do wonder if you may be better sticking with your PNG file as a text format like KML/CSV will be big. A PNG may be better for an internet-based game (reducing bandwidth). If you have a stand-alone scenario, most programming languages understand image formats well (especially if you call the GDAL libraries) and so I'm not convinced that a text-based format is even necessary here - but that's your choice of course.

Related Question