Shapely Polygon creating empty polygon

Israel Brewster ijbrewster at alaska.edu
Tue Jan 4 17:57:26 EST 2022


I’m running into an issue with shapely that is baffling me. Perhaps someone here can help out?

When running shapely directly from a python 3.8 interpreter, it works as expected:

>>> import shapely
>>> shapely.__version__
'1.8.0'
>>> from shapely.geometry import Polygon
>>> bounds = [-164.29635821669632, 54.64251856269729, -163.7631779798799, 54.845450778742546]
>>> print(Polygon.from_bounds(*bounds))
POLYGON ((-164.2963582166963 54.64251856269729, -164.2963582166963 54.84545077874255, -163.7631779798799 54.84545077874255, -163.7631779798799 54.64251856269729, -164.2963582166963 54.64251856269729))

However, if I put this exact same code into my Flask app (currently running under the Flask development environment) as part of handling a request, I get an empty polygon:

>>>    import shapely
>>>    print(shapely.__version__)
>>>    from shapely.geometry import Polygon
>>>    print(Polygon.from_bounds(*bounds))

Output:

1.8.0
POLYGON EMPTY

In fact, *any* attempt to create a polygon gives the same result:
>>> test = Polygon(((1, 1), (2, 1), (2, 2)))
>>> print(test)
POLYGON EMPTY

What am I missing here? Why doesn’t it work as part of a Flask request call?
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145



More information about the Python-list mailing list