Source code for rios.imageio
"""
The only things of value left in this module are the original definitions of
UNION, INTERSECTION and BOUNDS_FROM_REFERENCE.
There are also two functions wld2pix and pix2wld, and the Coord class they use.
These should also be deprecated, in favour of GDAL's ApplyGeoTransform
and InvGeoTransform (which they now use internally anyway).
However, they are used in public-facing ways in the ReaderInfo object,
so removing them would, in principle, be a breaking change.
They are harmless enough, so they have been left here.
In general, this module should be ignored.
"""
# This file is part of RIOS - Raster I/O Simplification
# Copyright (C) 2012 Sam Gillingham, Neil Flood
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from osgeo import gdal
INTERSECTION = 0
UNION = 1
BOUNDS_FROM_REFERENCE = 2 # Bounds of working region are taken from given reference grid
[docs]class Coord:
"""a simple class that contains one coord"""
def __init__(self, x, y):
self.x = x
self.y = y
[docs]def wld2pix(transform, geox, geoy):
"""converts a set of map coords to pixel coords"""
inv_transform = gdal.InvGeoTransform(transform)
x, y = gdal.ApplyGeoTransform(inv_transform, geox, geoy)
return Coord(x, y)
[docs]def pix2wld(transform, x, y):
"""converts a set of pixels coords to map coords"""
geox, geoy = gdal.ApplyGeoTransform(transform, x, y)
return Coord(geox, geoy)