Skip to content

WorldFile

Namespace: ThinkGeo.Core

This class represents the values of a world file.

public class WorldFile

Inheritance object → WorldFile

Remarks:

A world file is an attribute file that is associated with a corresponding image file. Typically, the world file consists of 6 lines of numbers.

Properties

HorizontalResolution

This property gets the horizontal resolution from the world file.

public float HorizontalResolution { get; }

Property Value

float
This property gets the horizontal resolution from the world file.

Remarks:

None

RotationRow

This property gets the rotation in row from the world file.

public float RotationRow { get; }

Property Value

float
This property gets the rotation in row from the world file.

Remarks:

None

RotationColumn

This property gets the rotation in column from the world file.

public float RotationColumn { get; }

Property Value

float
This property gets the rotation in column from the world file.

Remarks:

None

VerticalResolution

This property gets the vertical resolution from the world file.

public float VerticalResolution { get; }

Property Value

float
This property gets the vertical resolution from the world file.

Remarks:

None

UpperLeftX

This property gets the upper left Y coordinate from the world file.

public float UpperLeftX { get; }

Property Value

float
This property gets the upper left Y coordinate from the world file.

Remarks:

None

UpperLeftY

This property gets the upper left X coordinate from the world file.

public float UpperLeftY { get; }

Property Value

float
This property gets the upper left X coordinate from the world file.

Remarks:

None

Constructors

WorldFile()

This is the default constructor for the WorldFile class.

public WorldFile()

Remarks:

None

WorldFile(string)

This is the constructor that passes the worldFile text.

public WorldFile(string worldFileText)

Parameters

worldFileText string
The world file text containing the world file attribute information.

Remarks:

The worldFileText is typically read from a world file.

WorldFile(RectangleShape, float, float)

This is the constructor that passes the WorldExtent of the image, the height of the image, and the width of the image.

public WorldFile(RectangleShape worldExtent, float imageWidth, float imageHeight)

Parameters

worldExtent RectangleShape
This parameter specifies the World Coordinate Extent for the image.

imageWidth float
This parameter specifies the image width for the image.

imageHeight float
This parameter specifies the image height for the image.

WorldFile(double, double, double, double, double, double)

This is a constructor that passes 6 attributes in double associated with the corresponding image file.

public WorldFile(double horizontalResolution, double rotationRow, double rotationColumn, double verticalResolution, double upperLeftX, double upperLeftY)

Parameters

horizontalResolution double
This parameter specifies the size of pixels in the x direction.

rotationRow double
This parameter specifies the rotation term for row.

rotationColumn double
This parameter specifies the rotation term for column.

verticalResolution double
This parameter specifies the size of pixels in the y direction.

upperLeftX double
This parameter represents the x coordinate of the center of the upper-leftmost pixel in map units.

upperLeftY double
This parameter represents the y coordinate of the center of the upper-leftmost pixel in map units.

WorldFile(float, float, float, float, float, float)

This is a constructor that passes 6 attributes in float associated with the corresponding image file.

public WorldFile(float horizontalResolution, float rotationRow, float rotationColumn, float verticalResolution, float upperLeftX, float upperLeftY)

Parameters

horizontalResolution float
This parameter specifies the size of pixels in the x direction.

rotationRow float
This parameter specifies the rotation term for row.

rotationColumn float
This parameter specifies the rotation term for column.

verticalResolution float
This parameter specifies the size of pixels in the y direction.

upperLeftX float
This parameter represents the x coordinate of the center of the upper-leftmost pixel in map units.

upperLeftY float
This parameter represents the y coordinate of the center of the upper-leftmost pixel in map units.

Methods

TryLoadFromAuxXml(string, WorldFile&)

Tries to load a WorldFile from the GDAL PAM sidecar at "<imagePath>.aux.xml". Used by SDK raster sources as a fallback when no classic worldfile sidecar (e.g. .pgw, .wld) is present; modern GIS exports (QGIS, ArcGIS Pro, gdal_translate) often emit only this file.

public static bool TryLoadFromAuxXml(string imagePath, WorldFile& worldFile)

Parameters

imagePath string
Path to the underlying raster image. The aux.xml is expected at imagePath + ".aux.xml".

worldFile WorldFile&
On true, the worldfile reconstructed from the element (GDAL pixel-corner shifted to ESRI pixel-center). null otherwise.

Returns

bool
true if the sidecar existed, parsed cleanly, and described an axis-aligned transform; false on any parse/format failure so the caller can surface the original "missing worldfile" error and not mask GDAL-specific decode bugs.

Remarks:

GDAL GeoTransform layout is [ulx, pxX, rotX, uly, rotY, pxY] using the upper-left pixel CORNER as origin, whereas WorldFile (ESRI convention) uses the pixel CENTER, so this method shifts by half a pixel on both axes when constructing the result. Meaningfully non-zero rotation/skew is rejected (epsilon relative to pixel size) because downstream extent math computes an axis-aligned box from pixel size alone and silently ignores rotation — accepting a rotated transform here would open the file with subtly wrong georeferencing instead of failing the open.

GetBoundingBox(float, float)

Returns the bounding box that encloses the relevant geometry.

public RectangleShape GetBoundingBox(float width, float height)

Parameters

width float
The width, in pixels.

height float
The height, in pixels.

Returns

RectangleShape
The result of the operation.

Save(string)

Saves the current object to the specified destination.

public void Save(string pathFilename)

Parameters

pathFilename string
The path to the source file.

Returns

void