Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Martin Fleischmann
    @martinfleis
    Linearring is linear geometry (just that exterior line) while polygon covers an area it encloses.
    Shirzart Enwer
    @Aniwax
    Alright, got it, thanks!
    Alex Yule
    @yuletide
    Hey folks, working on a project and ran into a bunch of "illegalArgumentException: Geometry must be a Point or LineString" when exporting a dataframe to json (or passing it into rasterstats). Any idea what could cause this? The geometry seems valid and plots fine. I'm using Shapely 1.8a1 but unable to reproduce with sample data. This data is a large set of isochrones created using the Mapbox API.
    Happy to create a ticket but didn't want to clutter things up if there's something I should try first
    The project is analyzing internet connectivity in Kazakhstan for Unicef GIGA
    Martin Fleischmann
    @martinfleis
    I think we’ll need more info, code and ideally reproducible example or a some way to reproduce it. Best to file it as a bug or question on GitHub
    Alex Yule
    @yuletide
    Sounds good, I'll try to put together a smaller dataset that produces the same errors!
    Thanks Martin
    Shirzart Enwer
    @Aniwax
    Hey Guys, I have the issue of not the same version of GEOS used, when I try to install Shapely and Pygeos in the same environment on Github Actions to run my automated tests. I could resolved this problem on my machine by replacing the geos_c.dill file inside the Shapely package, but I don't know how to resolve it on the cloud. I am using Windows both on the cloud and local environment.
    Any suggestions? Appreciated :)
    Martin Fleischmann
    @martinfleis
    @Aniwax how are you installing shapely and pygeos? Try to use conda and conda-forge channel, which should resolve this. Check geopandas CI how we do it on GHA if you need an example.
    Shirzart Enwer
    @Aniwax
    I am using pip install @martinfleis but will try conda channel
    Martin Fleischmann
    @martinfleis
    pip install is not recommended for geopandas and its dependencies as it is not able to ensure compatibility of C libraries (like in this case)
    Shirzart Enwer
    @Aniwax
    Damn, alright. I usually prefer pip for my python environment management. But anyway, I will try this on the cloud. Thanks for your lightening-speed reply as always :)
    Shirzart Enwer
    @Aniwax
    Hi Community, I am wondering if there is any general guide on how to exploit the vectorized-operation the best to improve the runtime of code using pygeos?
    Appreciate any suggestions :)
    Martin Fleischmann
    @martinfleis
    I am not aware of a ready-made guide for geopandas (apart from the one on my long to-do list). Generally speaking, avoid for loops, avoid apply and try to rely as much as you can on built-in GeoSeries methods. If needed use the underlying array of pygeos geometries directly with pygeos functions. You can access it as gdf.geometry.values.data. When you can use numpy functions instead of for loops, use them. Look up some vectorization guide for pandas, the rules are fairly similar. And when using spatial index, use query_bulk.
    Shirzart Enwer
    @Aniwax
    Thanks ! As I am only using pygeos, not Geopandas, then it's quite straight forward in my case then I guess: use pygeos directly as much as possible, without breaking the design?
    Brendan Ward
    @brendan-ward
    @Aniwax correct: you can use the pygeos functions directly to leverage the speedups (they are already vectorized in most cases). There are a few cases where the pygeos functions operate on singular geometries where you may need to do a bit more to vectorize them (e.g., get_geometry), but we've been adding more functions to vectorize the most common operations where you would get these back as ragged arrays (e.g., get_parts), where there are varying numbers of geometries within arrays of multi / geometry collections.
    If you run into a case where trying to use pygeos to get what you need isn't obvious, certainly feel free to ask here.
    Shirzart Enwer
    @Aniwax
    @brendan-ward Thanks a lot :)
    Alex Yule
    @yuletide
    @martinfleis Ticket filed! #1943
    I created a minimal test dataset with one feature
    robertbozsik
    @robertbozsik
    Hi there,
    I've seen you have already talked about this warning in January.
    UserWarning: The Shapely GEOS version (3.8.0-CAPI-1.13.1 ) is incompatible with the GEOS version PyGEOS was compiled with (3.9.0-CAPI-1.16.2). Conversions between both will be slow.
    Is there any "pip install" solution to get rid of the warning besides installing geopandas with conda/conda forge?
    I would like to integrate a new geopandas spatial join feature into a package created by poetry and I cannot use a conda.
    Joris Van den Bossche
    @jorisvandenbossche
    I don't think there is an easy way with the current built wheels (except by installing from source). It might be that an older version of PyGEOS' wheels are built with GEOS 3.8.0, but not fully sure.
    (it might also be that you can ignore the warning, depending on your use case)
    robertbozsik
    @robertbozsik
    I could ignore the warning but this package is a command-line tool used by non-programmer colleagues to run some reports. It would be confusing for them to see a warning that they cannot understand.
    Can you please recommend any resource (link, video, blog post, ...) where I can check how to install from source?
    I also tried to use rtree instead of pygeos. Although the warning disappeared, the spatial join was much slower with rtree.
    Joris Van den Bossche
    @jorisvandenbossche
    The shapely readme (https://github.com/Toblerity/Shapely/) has some info about how to install from source. I think the main thing is to get an install of GEOS. Once that is available, installing shapely/pygeos from source is not that hard
    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