Michal Seidl
2016-08-19 13:18:00 UTC
Hello,
I am not sure if it is question about Python itself but I use shapely
1.5.16 version and I am facing behavior of geometry.is_valid property.
I want to catch is_valid messages but not mix with other stderr.
Redirecting stderr does not help.
This code:
============
import shapely.wkt
import sys
s1 = '''POLYGON ((0 0,0 1,2 2,0 0))'''
s2 = '''POLYGON ((0 0,1 1,2 2,0 0))'''
g1 = shapely.wkt.loads(s1)
g2 = shapely.wkt.loads(s2)
sys.stderr = open('/is_valid_err.log','w')
a = g1.is_valid
b = g2.is_valid
print(a)
print(b)
Returns:
===========
Self-intersection at or near point 0 0
True
False
Is there any way to suppress writing to stderr by 'is_valid'?
Thanks Michal
I am not sure if it is question about Python itself but I use shapely
1.5.16 version and I am facing behavior of geometry.is_valid property.
I want to catch is_valid messages but not mix with other stderr.
Redirecting stderr does not help.
This code:
============
import shapely.wkt
import sys
s1 = '''POLYGON ((0 0,0 1,2 2,0 0))'''
s2 = '''POLYGON ((0 0,1 1,2 2,0 0))'''
g1 = shapely.wkt.loads(s1)
g2 = shapely.wkt.loads(s2)
sys.stderr = open('/is_valid_err.log','w')
a = g1.is_valid
b = g2.is_valid
print(a)
print(b)
Returns:
===========
Self-intersection at or near point 0 0
True
False
Is there any way to suppress writing to stderr by 'is_valid'?
Thanks Michal