PythonAnywhere Forums

Shapely: Option to Turn off Intersection Warnings!

Hi All,

I’m using shapely in Python (3.6) running afffinity.transform many times where I expect intersections. Now, the “Self-intersection at or near point x y” warning is filling up my console unnecessarily. I tried blocking printing (which only stopped my print statements and not Shapely’s) and suppressing warnings (both snippets below) with no luck. Is there any way to stop Shapely from printing warnings to the console?

# Stop all printing
def blockPrint():
sys.stdout = open(os.devnull, w);

# Re-enable printing
def enablePrint():
sys.stdout = sys.__stdout__;

with warnings.catch_warnings():
p_i = shapely.affinity.translate(p_i, xoff=0, yoff=-2, zoff=0.0)

There's some info here that might be helpful depending on the version you're using.

I'm glad someone else has seen this problem (; now this begs the question, how do I disable INFO printing?

There's a code segment on that page that shows how.

I'm not sure how to de-awkward that level of not seeing something obvious, so.... thanks!

(I had scrolled right past it to the bottom then concluded it didn't exist, thanks again!)