warnings
python package, you can filter that specific UserWarning
GeoDataFrame
? I'm trying to quickly make many simple plots at once. I've tried variations on the following, but it feels a bit hacky.for feature in gdf.iterfeatures():
temp = gpd.GeoSeries(Point(*feat['geometry']['coordinates'][0]), crs=gdf.crs)
ax = temp.plot(figsize=(20, 20), color='red', marker='o', alpha=0.9)
ctx.add_basemap(ax=ax)
fig = ax.get_figure()
fig.savefig('.../out/path/...')
x_coords = np.array([[1, 2, 3], [4, 5, 6]])
y_coords = np.array([[1, 2, 3], [4, 5, 6]])
pygeos.polygons(pygeos.linearrings(x_coords, y=y_coords))
array([<pygeos.Geometry POLYGON ((1 1, 2 2, 3 3, 1 1))>,
<pygeos.Geometry POLYGON ((4 4, 5 5, 6 6, 4 4))>], dtype=object)
try to get your coordinates in a structure like this
numpy
, but I can be wrong
In [5]: polygons1 = pygeos.polygons(np.random.randn(10, 3, 2))
In [6]: polygons2 = pygeos.polygons(np.random.randn(10, 3, 2))
In [7]: pygeos.union(polygons1, polygons2)
Out[7]:
array([<pygeos.Geometry MULTIPOLYGON (((1.12 1.27, 0.677 -1.4, 1.27 -0.521, 1.12 1....>,
<pygeos.Geometry POLYGON ((-2.33 -0.959, -1.35 -0.317, 0.53 0.064, -0.602 1....>,
<pygeos.Geometry POLYGON ((0.69 -1.4, 0.454 -0.704, 0.0886 -0.934, 0.448 -0....>,
<pygeos.Geometry POLYGON ((-0.78 -1.96, -0.967 -0.353, -0.731 -0.221, -1.01 ...>,
<pygeos.Geometry POLYGON ((0.885 0.607, -0.62 -0.964, -0.213 -0.0648, -0.318...>,
<pygeos.Geometry POLYGON ((0.682 1.38, 0.68 -0.76, 0.215 -1.09, 0.755 -1.52,...>,
<pygeos.Geometry MULTIPOLYGON (((-1 0.0676, 1.21 -1.35, -0.0311 -1.23, -1 0....>,
<pygeos.Geometry MULTIPOLYGON (((-1.55 1.55, -0.198 -0.242, -0.614 0.613, -1...>,
<pygeos.Geometry POLYGON ((-0.661 0.291, -0.181 0.0644, 0.246 0.118, 0.861 -...>,
<pygeos.Geometry MULTIPOLYGON (((-0.702 2.27, 0.874 -1.25, -0.751 0.967, -0....>],
dtype=object)
In [8]: polygons = pygeos.polygons(np.random.randn(10, 3, 2))
In [9]: pygeos.union_all(polygons)
Out[9]: <pygeos.Geometry POLYGON ((-0.973 0.0936, -0.976 0.0886, -1.03 0.138, -1.1 0...>
pygeos.constructive.simplify( pygeos.set_operations.union_all(polygons), tolerance=default_precision)
in the debug console, there is no warning message shown
arr = 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))'
])
In [19]: pygeos.union_all(arr)
/home/joris/miniconda3/envs/geo/lib/python3.9/site-packages/pygeos/set_operations.py:388: RuntimeWarning: invalid value encountered in unary_union
result = lib.unary_union(collections, **kwargs)
Out[19]: <pygeos.Geometry POLYGON ((-0.961 0.109, -0.622 0.661, 0.16 0.98, 0.782 0.31...>
for me, if I run this cell, it gave me both errors:In [19]: pygeos.union_all(arr) /home/joris/miniconda3/envs/geo/lib/python3.9/site-packages/pygeos/set_operations.py:388: RuntimeWarning: invalid value encountered in unary_union result = lib.unary_union(collections, **kwargs) Out[19]: <pygeos.Geometry POLYGON ((-0.961 0.109, -0.622 0.661, 0.16 0.98, 0.782 0.31...>
c:\Users\aniwax\Documents\GitHub\ibrus_new_design\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:\Users\aniwax\Documents\GitHub\ibrus_new_design\ibrus-env\lib\site-packages\pygeos\set_operations.py:388: RuntimeWarning: invalid value encountered in unary_union
result = lib.unary_union(collections, **kwargs)
<pygeos.Geometry POLYGON ((-0.961 0.109, -0.622 0.661, 0.16 0.98, 0.782 0.31...>