def lat_long_to_idx(gt, lon, lat):
    """
        Take a geotransform and calculate the array indexes for the given lat,long.

        :param gt: GDAL geotransform (e.g. gdal.Open(x).GetGeoTransform()).
        :type gt: GDAL Geotransform tuple.
        :param lon: Longitude.
        :type lon: float
        :param lat: Latitude.
        :type lat: float
    """
    return (int((lat - gt[3]) / gt[5]),
            int((lon - gt[0]) / gt[1]))