Trying to add taxonomy to get_categories() but it’s not working. How to fix this?

Use :

$terms = get_terms( 'location', 'hide_empty=0' );
if(is_wp_error($terms)){
    // error occurred
} else if (empty($terms )){
    // no terms were found
} else {
    // process terms
    foreach($terms as $term){
        // process this individual $term
    }
}

I’d advise you use the generic taxonomy & term functions everywhere, and avoid the special case category and tag functions where possible.