Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Obviously I was either onto something, or on something. -- Larry Wall on the creation of Perl


devel / comp.lang.python / Re: Shapely Polygon creating empty polygon

SubjectAuthor
o Re: Shapely Polygon creating empty polygonIsrael Brewster

1
Re: Shapely Polygon creating empty polygon

<mailman.110.1641404900.3079.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16596&group=comp.lang.python#16596

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ijbrews...@alaska.edu (Israel Brewster)
Newsgroups: comp.lang.python
Subject: Re: Shapely Polygon creating empty polygon
Date: Wed, 5 Jan 2022 08:48:14 -0900
Lines: 86
Message-ID: <mailman.110.1641404900.3079.python-list@python.org>
References: <2DB2FC25-8FEC-4063-BAFD-068AFC6DC89D@alaska.edu>
<9CCDAE3E-AF6F-4287-B98E-A4AE58D6CC07@alaska.edu>
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de Hlt76r334HP+rBn9f0JDUwaPTjK9GRBKaEM6SSbSVc+Q==
Return-Path: <ijbrewster@alaska.edu>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=alaska.edu header.i=@alaska.edu header.b=LxhR9KlC;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'engineer': 0.02; '3.8':
0.05; 'cell:': 0.05; 'issue.': 0.05; 'skip:5 30': 0.05;
'apparently': 0.09; 'fact,': 0.09; 'output:': 0.09; 'skip:[ 20':
0.09; 'import': 0.15; '1),': 0.16; '2022,': 0.16; 'israel': 0.16;
'skip:5 20': 0.16; 'subject:creating': 0.16; 'work:': 0.16;
'wrote:': 0.16; 'python': 0.16; 'helvetica;': 0.19; 'pm,': 0.19;
'to:addr:python-list': 0.20; 'issue': 0.21; 'code': 0.23; 'skip:p
30': 0.23; 'anything': 0.25; 'skip:- 10': 0.25; 'flask': 0.26;
'>>>': 0.28; 'attempt': 0.31; 'empty': 0.32; 'to:name:python':
0.32; 'skip:2 10': 0.32; 'but': 0.32; '0);': 0.33; 'rgb(0,': 0.33;
'someone': 0.34; 'same': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'running': 0.34; 'handling': 0.35;
'request': 0.35; 'missing': 0.37; 'received:209.85': 0.37; 'put':
0.38; '8bit%:14': 0.38; 'received:209': 0.39; 'exact': 0.40;
'font-family:': 0.60; 'skip:o 10': 0.61; 'me.': 0.62; 'none;':
0.62; 'gives': 0.62; 'here': 0.62; 'font-weight:': 0.62; '0px;':
0.63; 'skip:b 10': 0.63; 'text-indent:': 0.64; 'normal;': 0.66;
'skip:e 20': 0.67; 'skip:9 10': 0.68; 'order': 0.69; 'none;"':
0.69; 'bounds': 0.84; 'geophysical': 0.84; 'skip:p 50': 0.84;
'received:10.25': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alaska.edu; s=google;
h=from:mime-version:subject:date:references:to:in-reply-to:message-id;
bh=LOrBtzNnstfR1bt2GTPR+Wg1mvmZblC2j26UlZa4VnA=;
b=LxhR9KlCWzO+pEpetWkAZJx9RGcA1/1F0N5ck/PXm1Gc9fjwYUGJU6FcP9YLZtPh3e
qjPHC0S81s8WztOfnCYRHxx8l+eZbAE90cMtz/r0+hkeFhDmzD/0fG/n8aNw/gK2DTgg
nMsQKqvLLutIjD8sbV6SCT1LCv/LZGm227DoBl2A8wCS4wZObQFwf21KiBLXFj/vu6LD
VPrQT7EgfSMn7iKgOKToVxgXOjDAFSYHEWXiHQxZq8QkR/DqujHH9VCo27W+c96E0VVW
o9/Yb0sTG/Z0SKNjzkv7MJ70u2XoQkyoDuknv5Yyq9QeoB91/5Sx0JDKamgKBzeaUaPq
ArmQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:from:mime-version:subject:date:references:to
:in-reply-to:message-id;
bh=LOrBtzNnstfR1bt2GTPR+Wg1mvmZblC2j26UlZa4VnA=;
b=zDd7FVWF333YJQDNK22B4EXSyQj+6EDr/xsFE3zc7fdAOvwjy0oj+3Yf3cIi+WeLoj
SmAGH/ChMr9tk/3JORvwh58eVJph/OxK5orQQGlg0pLsbSVjfCUxge6MYas4cCxaqZXj
b6SHI5oA+in+XMbiEbupHNmoTk0cXUqBCtj7/St4NN4dzGtwVCYHTMNkMqCOi9VP6+CN
Ls9ZmmTS1byPbqFwhP0WpsoHoqHqNFhtiXgfqq5f/BzCcqVdDKsUQzOMNyRJDHrx+C6A
azBV22CNZckz/1wyos46iKUWYGm6qSlG6v/cXuWatEu5CYyIBCfca405wrIabv+qk0b1
s9vA==
X-Gm-Message-State: AOAM533M6W93j9+i5d5zIm8Wo4pFTLFzIAqT3zQKCpv1lpcMt9AzDc/8
W0Jh7w9QFPQhmG4PJcYyCqCrEMXWbfeu9pTxwigoh826ZXmOZivtszBkWonGhgza9jTn3Ibfatm
Yh4LK6XELitdxs236DF001pGsqZiQjRAgX9ig2Rpb5wTIRm+lYngcVLd7JVLX7rtPpLotLg==
X-Google-Smtp-Source: ABdhPJxpaWNT2GdgqmFTvpJSJzkLVUxN4xFN1Ve7RUux2k2wf9Tcsi38rQyM3QimYuY7GlLyNzE1rA==
X-Received: by 2002:a17:902:8c97:b0:148:ce06:eff9 with SMTP id
t23-20020a1709028c9700b00148ce06eff9mr54812403plo.5.1641404896203;
Wed, 05 Jan 2022 09:48:16 -0800 (PST)
In-Reply-To: <2DB2FC25-8FEC-4063-BAFD-068AFC6DC89D@alaska.edu>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <9CCDAE3E-AF6F-4287-B98E-A4AE58D6CC07@alaska.edu>
X-Mailman-Original-References: <2DB2FC25-8FEC-4063-BAFD-068AFC6DC89D@alaska.edu>
 by: Israel Brewster - Wed, 5 Jan 2022 17:48 UTC

Found it! Apparently, it’s an import order issue. This works:

>>> from shapely.geometry import Polygon
>>> from osgeo import osr
>>> 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))

But this doesn’t:

>>> from osgeo import osr
>>> from shapely.geometry import Polygon
>>> bounds = [-164.29635821669632, 54.64251856269729, -163.7631779798799, 54.845450778742546]
>>> print(Polygon.from_bounds(*bounds))
POLYGON EMPTY

…So apparently I have to make sure to import shapely *before* I import anything from osgeo. Why? I have no idea...
---
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

> On Jan 4, 2022, at 1:57 PM, Israel Brewster <ijbrewster@alaska.edu> wrote:
>
> 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
>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor