question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeWarning encountered for unary_union operations.

See original GitHub issue

I have a set of polygons:

'POLYGON ((-0.961 0.109, -0.16 -0.98, -0.782 -0.319, -0.961 0.109))',
 'POLYGON ((-0.782 -0.319, -0.622 0.661, -0.961 0.109, -0.782 -0.319))',
 'POLYGON ((-0.179 0.428, -0.961 0.109, -0.622 0.661, -0.179 0.428))',
 'POLYGON ((0.179 -0.428, -0.16 -0.98, 0.622 -0.661, 0.179 -0.428))',
 'POLYGON ((0.179 -0.428, -0.782 -0.319, -0.16 -0.98, 0.179 -0.428))',
 'POLYGON ((0.179 -0.428, -0.622 0.661, -0.782 -0.319, 0.179 -0.428))',
 'POLYGON ((0.782 0.319, 0.622 -0.661, -0.179 0.428, 0.782 0.319))',
 'POLYGON ((0.16 0.98, -0.179 0.428, -0.622 0.661, 0.16 0.98))',
 'POLYGON ((0.16 0.98, 0.782 0.319, -0.179 0.428, 0.16 0.98))',
 'POLYGON ((-0.339 -0.552, -0.179 0.428, 0.622 -0.661, -0.339 -0.552))',
 'POLYGON ((-0.339 -0.552, -0.16 -0.98, -0.961 0.109, -0.339 -0.552))'

when performing union_all() on them, 2 RuntimeWarning are generated:

polygons = pygeos.from_wkt(
      ['POLYGON ((-0.961 0.109, -0.16 -0.98, -0.782 -0.319, -0.961 0.109))',
       'POLYGON ((-0.782 -0.319, -0.622 0.661, -0.961 0.109, -0.782 -0.319))',
       'POLYGON ((-0.179 0.428, -0.961 0.109, -0.622 0.661, -0.179 0.428))',
       'POLYGON ((0.179 -0.428, -0.16 -0.98, 0.622 -0.661, 0.179 -0.428))',
       'POLYGON ((0.179 -0.428, -0.782 -0.319, -0.16 -0.98, 0.179 -0.428))',
       'POLYGON ((0.179 -0.428, -0.622 0.661, -0.782 -0.319, 0.179 -0.428))',
       'POLYGON ((0.782 0.319, 0.622 -0.661, -0.179 0.428, 0.782 0.319))',
       'POLYGON ((0.16 0.98, -0.179 0.428, -0.622 0.661, 0.16 0.98))',
       'POLYGON ((0.16 0.98, 0.782 0.319, -0.179 0.428, 0.16 0.98))',
       'POLYGON ((-0.339 -0.552, -0.179 0.428, 0.622 -0.661, -0.339 -0.552))',
       'POLYGON ((-0.339 -0.552, -0.16 -0.98, -0.961 0.109, -0.339 -0.552))'
      ])      
pygeos.union_all(polygons )
C:\ibrus-env\lib\site-packages\pygeos\set_operations.py:388: RuntimeWarning: divide by zero encountered in unary_union
  result = lib.unary_union(collections, **kwargs)
C:\ibrus-env\lib\site-packages\pygeos\set_operations.py:388: RuntimeWarning: invalid value encountered in unary_union
  result = lib.unary_union(collections, **kwargs)

I don’t know what exactly triggered this warning and if it affects the calculation result of union operations.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
martinfleiscommented, Jun 3, 2021

I just want to note that pygeos returns the correct result, the same as shapely. It just emits those warnings along the way.

1reaction
jorisvandenbosschecommented, Jun 2, 2021

You can check pygeos.geos_version

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get rid of "RuntimeWarning: invalid value encountered ...
I basically want to calculate array > 0.5 , but without the warning showing up. My restrictions: I do NOT want to just...
Read more >
How to Fix: runtimewarning: invalid value encountered in ...
This error simply occurs when we performing a math operation and we encounter which is not valid as input. When we perform some...
Read more >
runtimewarning: invalid value encountered in double_scalars
This error occurs when you attempt to perform some mathematical operation that involves extremely small or extremely large numbers and Python ...
Read more >
Set operations — pygeos documentation - Read the Docs
Returns the union of multiple polygons of a geometry collection. This is an optimized version of union which assumes the polygons to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found