Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Joris Van den Bossche
    @jorisvandenbossche
    If it's just for the warning being visible, you could also suppress the warning with the warnings python package, you can filter that specific UserWarning
    Martin Fleischmann
    @martinfleis
    Just heads up that we'll be working on centralised XYZ services package (geopandas/contextily#153) today. I am going to create a new repo for that under geopandas org.
    robertbozsik
    @robertbozsik
    Thank you for your recommendation, @jorisvandenbossche!
    I managed to suppress the UserWarning with this small code snippet at the top of the main file of the package:
    import warnings warnings.filterwarnings("ignore", message="The Shapely GEOS version")
    and-viceversa
    @and-viceversa
    Hello all! What is the best way to plot each individual feature from a 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/...')
    Martin Fleischmann
    @martinfleis
    Hi all, the link for the meeting is here https://meet.google.com/bfa-crgm-cbn
    Levi John Wolf
    @ljwolf
    I won’t be able to attend this one! My apologies
    Shirzart Enwer
    @Aniwax

    Hey guys,

    A question here about constructing polygons with 3 points using pygeos.polygons. I got Invalid number of points in LinearRing found 3. Is there a way to get around this?

    Shirzart Enwer
    @Aniwax
    I see a similar discussion here pygeos/pygeos#150. But before any progress there, is there any quick fix to detect and remove the invalid points?
    Martin Fleischmann
    @martinfleis
    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
    Shirzart Enwer
    @Aniwax
    Great! It works out of the box. Thanks @martinfleis
    Shirzart Enwer
    @Aniwax
    Hey guys,
    I encountered 'divided by zero' error, while using union. The error message is RuntimeWarning: divide by zero encountered in unary_union result = lib.unary_union(collections, **kwargs). What would have caused this error? And is there a quick fix?
    Martin Fleischmann
    @martinfleis
    are all your polygons valid? never seen this error in union
    Shirzart Enwer
    @Aniwax
    I didn't get polygon invalid error...I use pygeos.make_valid() if I found any invalid polygons during the process.
    Martin Fleischmann
    @martinfleis
    if you are able to figure out which geometries are causing this, you may want to report it to pygeos repo. This error message makes a little sense in this context.
    Shirzart Enwer
    @Aniwax
    Will try :)
    Strange thing is, the error message is just one line. It doesn't show in which line of my code was this error triggered
    Martin Fleischmann
    @martinfleis
    I guess that's because it comes from GEOS not pygeos
    Shirzart Enwer
    @Aniwax
    I can verify it's not because of invalid polygons. I implemented a check and report for invalid polygons before doing union. But there was nothing reported.
    Martin Fleischmann
    @martinfleis
    if you manage to get a minimal reproducible example so we can debug it and report it to pygeos, that would be the best way to deal with it
    Joris Van den Bossche
    @jorisvandenbossche
    The "RuntimeWarning: divide by zero encountered in" suspiciously looks like a numpy warning, though. But not sure where numpy would introduce it
    Do you have a small reproducible example that triggers the warning?
    Shirzart Enwer
    @Aniwax
    This is the full warning message: \ibrus-env\lib\site-packages\pygeos\set_operations.py:388: RuntimeWarning: divide by zero encountered in unary_union result = lib.unary_union(collections, **kwargs)
    from this I am guessing it's not fromnumpy, but I can be wrong
    Joris Van den Bossche
    @jorisvandenbossche
    (with "from numpy", I didn't mean from a direct numpy call, but we are using numpy's C API to implement those ufuncs in C, so it's still running numpy's machinery although calling a pygeos function)
    As for a reproducible example, trying something very simple:
    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)
    So that doesn't raise a warning. But now it would be interesting to know what characteristic in polygons1/polygons2 would trigger such a warning
    Although you are actually using a unary union, I see. So the example would be:
    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...>
    Shirzart Enwer
    @Aniwax
    wait, I will get all the numbers
    Shirzart Enwer
    @Aniwax
    Here is a list of polygons, that when I executed the following lines, a RuntimeWarning was catched:
    try: area2d.area = pygeos.constructive.simplify( pygeos.set_operations.union_all(polygons), tolerance=default_precision) except RuntimeWarning: print(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))
    but when I just run pygeos.constructive.simplify( pygeos.set_operations.union_all(polygons), tolerance=default_precision) in the debug console, there is no warning message shown
    Shirzart Enwer
    @Aniwax
    Could you reproduce this scenario?
    Joris Van den Bossche
    @jorisvandenbossche
    Yes
    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...>
    Thanks!
    Shirzart Enwer
    @Aniwax
    You're welcome :)
    Do I need to post this on pygeos repo as issue?
    Joris Van den Bossche
    @jorisvandenbossche
    Although it gives "invalid value" for me, and not "divide by zero encountered"
    But in any case also the "invalid value" warning is confusing
    Shirzart Enwer
    @Aniwax
    I had both cases.
    But don't know how to catch them differently
    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:
    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...>
    Joris Van den Bossche
    @jorisvandenbossche
    I think it's worth opening a pygeos issue for it
    Shirzart Enwer
    @Aniwax
    :thumbsup:
    Shirzart Enwer
    @Aniwax
    Joris Van den Bossche
    @jorisvandenbossche
    thanks!
    Shirzart Enwer
    @Aniwax
    Hey guys, I have a question out of curiosity: how much faster is it to run pygeos module with pypy instead of python?