Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Aleksey Bilogur
    @ResidentMario
    LMK if you have an opinion on the pattern I proposed there? https://github.com/ResidentMario/geoplot/issues/163#issuecomment-516944692
    There's some residual inflexibility in the API that I'm working on finding and fixing right now before I do any more feature work on the library. Really want to get all these kinks sorted out...
    hannah
    @story645
    @ResidentMario
    Aleksey Bilogur
    @ResidentMario
    ?
    awa5114
    @awa5114
    I added tests as requested for geopandas/geopandas#1009 but one of the travis builds is failing. Any ideas? Thanks
    hannah
    @story645
    @ResidentMario sorry was on my phone and it does stupid things some times
    Dani Arribas-Bel
    @darribas
    here's a question: I have a GeoDataFrame of polygons and a GeoSeries with a single MultiLineString; how could I end up with a GeoSeries with one row per segments of the original line that are inside a polygon (and the polygon ID too)?
    tentatively I think it'd be an overlay?
    Martin Fleischmann
    @martinfleis
    explode and intersects?
    Martin Fleischmann
    @martinfleis
    Explode will will explode MultiLineString into LineStrings. Do you mean that by segment or point-point segment? If the latter I would do the explode anyway and then some iteration over segments of each LineString checking either within or intersects. Alternatively, if segment is part of MultiLineString inside a polygon (no matter if LineString of MultiLineString) overlay intersection might help as you suggested.
    Dani Arribas-Bel
    @darribas
    I think what I have in mind is more fit for overlay, however it does not seem to accept line-based geodataframes. I'm thinking a solution could be to create a (very small) buffer around the line and then pass it on to overlay...
    will report if there's progress...
    Joris Van den Bossche
    @jorisvandenbossche
    @darribas yes, I think that is the use case of overlay
    if it supported lines
    There isn't an open issue about it, but I listed it some time ago in this issue (last bullet point): geopandas/geopandas#706
    I think it should work with not much work
    However, if you only have a single MultiLineString, you can do it with intersection, I think?
    Joris Van den Bossche
    @jorisvandenbossche
    gdf_polys.intersection(multi_line_scalar) and then filter away the empties
    Dani Arribas-Bel
    @darribas
    thanks Joris! Although, if I get it correctly, the last approach would not give me back a break up of the line into segments that are inside different polygons, right?
    for my application, a minimal buffer might actually be intuitive (as it's a bike ride so you could assume it approximates the street/path
    Joris Van den Bossche
    @jorisvandenbossche

    if I get it correctly, the last approach would not give me back a break up of the line into segments that are inside different polygons, right?

    I think it does?

    unless I misunderstand what you want
    I am assuming that you have a long multilinestring (a path or street network?) and polygons. If you do such intersection, you create all different (multi)linestrings, subsets of the original long multilinestring that fall within one of the polygons
    Dani Arribas-Bel
    @darribas
    no, I'd like the one linestring split into segments that correspond to the bit of the linestring that is within one polygon
    Joris Van den Bossche
    @jorisvandenbossche
    isn't that the same but in other (clearer) words ?
    We should probably do some code :)
    Dani Arribas-Bel
    @darribas
    :joy:
    I have a sketch notebook, will shared when finished
    also, it's a toy project so might not be immediate :)
    Joris Van den Bossche
    @jorisvandenbossche
    Small example of how I understood it:
    # one (multi)linestring and a set of polygons
    l = LineString([(-1, -1), (1, 1), (2, 2), (3, 4), (5, 5)])
    polys = geopandas.GeoSeries([box(0, 0, 4, 1), box(0, 1, 4, 3), box(0,3,4,4)])
    
    # plot them together
    ax = polys.plot(cmap='viridis')
    geopandas.GeoSeries([l]).plot(color='red', linewidth=3, ax=ax)
    
    # creating multiple linestrings split per polygon
    res = polys.intersection(l)
    
    # illustrate result
    ax = polys.plot(cmap='viridis', alpha=.5)
    res.plot(linewidth=3, cmap='Set1', ax=ax)
    Figure_1.png
    that's the original linestring and multipl polygons
    and now the one linestring splitted in segments that correspond to the part that is within one of the polygons:
    Figure_1.png
    Dani Arribas-Bel
    @darribas
    ahh! yes!!! intersection it is then! I thought you were saying to use l.intersects(polys)
    I didn't know about intersection, pretty cool!
    Morenagl
    @Morenagl

    hello, I have a problem with importing geopandas package, I have created my new environment in Conda and I the installation has done but in jupyter book doesn t work
    geopandas

    and the error Command "python setup. py egg_info" failed with error code 1 in C so I have noticed that it's not in the same path I mean the same environment which is normal that it could not do it, so how can I change the environment in jupyter book just to import geopandas and the same time not lose all my packages in Conda because I have found already trouble with pysal package and I don't want they have the same issue
    thank you

    Henrikki Tenkanen
    @HTenkanen
    @jorisvandenbossche Opened an issue about nearest spatial join -feature with an example and a first implementation of the function that gives an idea how the function could work: geopandas/geopandas#1096
    Joris Van den Bossche
    @jorisvandenbossche
    @HTenkanen Thanks!
    Isaac Boates
    @iboates
    Hey guys, just wondering, is there any current work going on to add functionality for converting a geodataframe directly to a geojson in Python json format?
    I was looking for that functionality earlier and from what I saw, it seems that you can only go to geojson as a file, not as a native Python object, and I was thinking it could be useful and that I might have a go at it but I wanted to see if there was anyone else already working on it
    Martin Fleischmann
    @martinfleis
    I am guessing here as I am usually not using GeoJSON, but have you tried gdf.to_json()? If I'll do json = gdf.to_json() gdf = gpd.read_file(json)
    it looks okay.
    Isaac Boates
    @iboates
    oh weird
    it must have slipped past me
    haha, i came up with a totally roundabout solution of writing to a tempfile and then reading it
    Alan Barzilay
    @alan-barzilay
    Hi, does geopandas has some sort of "vectorized" method of converting a series of tuples or 2 lat/long float series into a series of shapely.geometry.Point objects? Something like the pandas Series.astype() function with support for the Point object.
    I searched the documentation but couldn't find anything, for now, I'm using the apply function with the Point constructor but this is really slow.
    It is missing in reference guide (as many others), so it is hard to find atm.
    Alan Barzilay
    @alan-barzilay
    I see, thank you! I'm going to test it out