i have researched regarding making world file format and tried to create one using c++ in windows, can somebody confirm if where i am getting the values from are correct? the literature regarding world file formats are quite vague. i don't use rotation so i assume value D and E are always zero..
Line 1: A: pixel size in the x-direction in map units/pixel.
p->GetDeviceCaps(HORZRES); // HORZRES is defined in wingdi.h as Horizontal width in
pixels
Line 2: D: rotation about y-axis // always 0 as i don't use rotation
Line 3: B: rotation about x-axis // always 0 as i don't use rotation
Line 4: E: pixel size in the y-direction in map units, almost always negative
p->GetDeviceCaps(VERTRES); // VERTRES is defined in wingdi.h as Horizontal width in
pixels
Line 5: C: x-coordinate of the center of the upper left pixel
// how do you get this value?
Line 6: F: y-coordinate of the center of the upper left pixel
// how do you get this value?
Best Answer
World files, as used by Esri, GDAL etc.. have a standard format:
Normally the rotation is 0 for both values (not rotated) but the values form a 6 parameter Affine Transformation between cells and the world; if you understand the maths then you could conceivably populate those numbers for a fine rotation. Here is some code for a GDAL GeoTransform array that is very similar to a world file:
Whereas a world file is populated like:
Note that N-S pixel size is always negative as rasters start at the upper left and read downward. All values are in world units (metres, feet, degrees, inches etc.).
Here is an example of how I would calculate/create a world file in Esri objects:
As you can see from the application you must know how many pixels the window is but also what extent 'on the ground' that those pixels represent. If you are writing your own application you must know these values at some point as it's intrinsic to rendering to display.