This is how I get the min and max points of the view rectangle in 2D:
# Get the canvas transform
var ctrans = get_canvas_transform()
# The canvas transform applies to everything drawn,
# so scrolling right offsets things to the left, hence the '-' to get the world position.
# Same with zoom so we divide by the scale.
var min_pos = -ctrans.get_origin() / ctrans.get_scale()
# The maximum edge is obtained by adding the rectangle size.
# Because it's a size it's only affected by zoom, so divide by scale too.
var view_size = get_viewport_rect().size / ctrans.get_scale()
var max_pos = min_pos + view_size
# Note: rotation is not taken into account here. An improvement would be
# to use the inverse transform instead of this.
Probably not a general solution but it works for me^^