<small id='tl3Ao'></small><noframes id='tl3Ao'>

      <tfoot id='tl3Ao'></tfoot>
        <i id='tl3Ao'><tr id='tl3Ao'><dt id='tl3Ao'><q id='tl3Ao'><span id='tl3Ao'><b id='tl3Ao'><form id='tl3Ao'><ins id='tl3Ao'></ins><ul id='tl3Ao'></ul><sub id='tl3Ao'></sub></form><legend id='tl3Ao'></legend><bdo id='tl3Ao'><pre id='tl3Ao'><center id='tl3Ao'></center></pre></bdo></b><th id='tl3Ao'></th></span></q></dt></tr></i><div id='tl3Ao'><tfoot id='tl3Ao'></tfoot><dl id='tl3Ao'><fieldset id='tl3Ao'></fieldset></dl></div>

      1. <legend id='tl3Ao'><style id='tl3Ao'><dir id='tl3Ao'><q id='tl3Ao'></q></dir></style></legend>
          <bdo id='tl3Ao'></bdo><ul id='tl3Ao'></ul>

      2. 将一个 GeoPandas 数据框中的每个点链接到另一个数

        时间:2023-09-11
      3. <small id='ILiY3'></small><noframes id='ILiY3'>

          1. <tfoot id='ILiY3'></tfoot>

              <i id='ILiY3'><tr id='ILiY3'><dt id='ILiY3'><q id='ILiY3'><span id='ILiY3'><b id='ILiY3'><form id='ILiY3'><ins id='ILiY3'></ins><ul id='ILiY3'></ul><sub id='ILiY3'></sub></form><legend id='ILiY3'></legend><bdo id='ILiY3'><pre id='ILiY3'><center id='ILiY3'></center></pre></bdo></b><th id='ILiY3'></th></span></q></dt></tr></i><div id='ILiY3'><tfoot id='ILiY3'></tfoot><dl id='ILiY3'><fieldset id='ILiY3'></fieldset></dl></div>
                <legend id='ILiY3'><style id='ILiY3'><dir id='ILiY3'><q id='ILiY3'></q></dir></style></legend>
                  <bdo id='ILiY3'></bdo><ul id='ILiY3'></ul>
                    <tbody id='ILiY3'></tbody>
                  本文介绍了将一个 GeoPandas 数据框中的每个点链接到另一个数据框中的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我搜索了我的问题,发现这个问题与我的问题不同.

                  I searched for my problem and found this question which is different from my issue.

                  我有两个地理数据框,一个包含房屋位置作为 points(约 700 个点),另一个包含 suburbs names 及其 polygon(约 2973 个多边形).我想将每个点链接到一个多边形,以将每个房屋分配到正确的郊区.

                  I have two geo data frames, one contains houses locations as points (~700 points) and the other contains suburbs names and their polygon (~2973 polygons). I want to link each point to a polygon to assign each house to the correct suburb.

                  我的地理数据框示例

                  import geopandas as gpd
                  from shapely.geometry import Point
                  from shapely.geometry.polygon import Polygon
                  
                  #creating geo series
                  polys = gpd.GeoSeries({
                      '6672': Polygon([(142.92288, -37.97886,), (141.74552, -35.07202), (141.74748, -35.06367)]),
                      '6372': Polygon([(148.66850, -37.40622), (148.66883, -37.40609), (148.66920, -37.40605)]),
                  })
                  
                  #creating geo dataframe
                  polysgdf = gpd.GeoDataFrame(geometry=gpd.GeoSeries(polys))
                  polysgdf
                  

                  这会产生以下内容(我的原始地理数据框还包含一个 suburb 列,其中包含郊区名称,但我无法将其添加到我的示例中,您只能在下面看到郊区 ID)

                  Which produces the following(my original geo dataframe also includes a suburb column that contains the suburb name but I couldn't add it to my sample, you can only see the suburb ID below)

                          geometry
                  6672    POLYGON ((142.92288 -37.97886, 141.74552 -35.07202, 141.74748 -35.06367, 142.92288 -37.97886))
                  6372    POLYGON ((148.66850 -37.40622, 148.66883 -37.40609, 148.66920 -37.40605, 148.66850 -37.40622))
                  

                  点地理数据框示例

                  points=[Point(145.103,-37.792), Point(145.09720, -37.86400), 
                          Point(145.02190, -37.85450)]
                  
                  pointsDF = gpd.GeoDataFrame(geometry=points,
                                                    index=['house1_ID', 'house2_ID', 'house3_ID'])
                  
                  pointsDF
                  

                  这会产生以下内容

                              geometry
                  house1_ID   POINT (145.10300 -37.79200)
                  house2_ID   POINT (145.09720 -37.86400)
                  house3_ID   POINT (145.02190 -37.85450)
                  

                  我希望最终输出是 pointsDF 地理数据框,每个房屋都分配到相应的郊区.作为匹配点和多边形的结果.

                  I would like the final output to be the pointsDF geo dataframe with each house assigned to the corresponding suburb. As a result of matching the points and the polygons.

                  例子:

                  suburbID subrubName    house_ID
                  6672      south apple  house1_ID
                  6372      water garden house2_ID
                  

                  我是 GeoPandas 的新手,我试图以最清晰的方式解释我的问题.我很高兴澄清任何一点.谢谢.

                  I am new to GeoPandas, I tried to explain my question in the clearest way possible. I am happy to clarify any point. Thank you.

                  推荐答案

                  我找到了一种方法来实现这一点,方法是使用 空间连接

                  I found a way to accomplish this by joining the two data frames using a spatial join

                  joinDF=gpd.sjoin(pointsDF, polysgdf, how='left',op="within")
                  

                  这篇关于将一个 GeoPandas 数据框中的每个点链接到另一个数据框中的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Python 中用空圆圈绘制散点图? 下一篇:找到给定点的最小面积矩形以计算长轴和短轴长

                  相关文章

                  最新文章

                  <legend id='1D0jX'><style id='1D0jX'><dir id='1D0jX'><q id='1D0jX'></q></dir></style></legend>

                    • <bdo id='1D0jX'></bdo><ul id='1D0jX'></ul>

                  1. <tfoot id='1D0jX'></tfoot>

                    <small id='1D0jX'></small><noframes id='1D0jX'>

                  2. <i id='1D0jX'><tr id='1D0jX'><dt id='1D0jX'><q id='1D0jX'><span id='1D0jX'><b id='1D0jX'><form id='1D0jX'><ins id='1D0jX'></ins><ul id='1D0jX'></ul><sub id='1D0jX'></sub></form><legend id='1D0jX'></legend><bdo id='1D0jX'><pre id='1D0jX'><center id='1D0jX'></center></pre></bdo></b><th id='1D0jX'></th></span></q></dt></tr></i><div id='1D0jX'><tfoot id='1D0jX'></tfoot><dl id='1D0jX'><fieldset id='1D0jX'></fieldset></dl></div>