cartopy.io.img_nest.Img#
- class cartopy.io.img_nest.Img(*args, **kwargs)[source]#
Represents a simple geo-located image.
- Parameters:
filename – Filename of the image tile.
extent – The (x_lower, x_upper, y_lower, y_upper) extent of the image in units of the native projection.
origin – Name of the origin.
pixel_size – The (x_scale, y_scale) pixel width, in units of the native projection per pixel.
Note
API is likely to change in the future to include a CRS.
- count(value, /)#
Return number of occurrences of value.
- extent#
Alias for field number 1
- filename#
Alias for field number 0
- classmethod from_world_file(img_fname, world_fname)[source]#
Return an Img instance from the given image filename and worldfile filename.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- origin#
Alias for field number 2
- pixel_size#
Alias for field number 3
- static world_file_extent(worldfile_handle, im_shape)[source]#
Return the extent
(x0, x1, y0, y1)
and pixel size(x_width, y_width)
as defined in the given worldfile file handle and associated image shape(x, y)
.
- static world_files(fname)[source]#
Determine potential world filename combinations, without checking their existence.
For example, a
'*.tif'
file may have one of the following popular conventions for world file extensions'*.tifw'
,'*.tfw'
,'*.TIFW'
or'*.TFW'
.Given the possible world file extensions, the upper case basename combinations are also generated. For example, the file ‘map.tif’ will generate the following world file variations, ‘map.tifw’, ‘map.tfw’, ‘map.TIFW’, ‘map.TFW’, ‘MAP.tifw’, ‘MAP.tfw’, ‘MAP.TIFW’ and ‘MAP.TFW’.
- Parameters:
fname – Name of the file for which to get all the possible world filename combinations.
- Returns:
A list of possible world filename combinations.
Examples
>>> from cartopy.io.img_nest import Img >>> Img.world_files('img.png')[:6] ['img.pngw', 'img.pgw', 'img.PNGW', 'img.PGW', 'IMG.pngw', 'IMG.pgw'] >>> Img.world_files('/path/to/img.TIF')[:2] ['/path/to/img.tifw', '/path/to/img.tfw'] >>> Img.world_files('/path/to/img/with_no_extension')[0] '/path/to/img/with_no_extension.w'