Distance between a point and a MultiPolygon Geoseries object in pythonCalculating distance between linestring...

How to deal with a cynical class?

Official degrees of earth’s rotation per day

How is the Swiss post e-voting system supposed to work, and how was it wrong?

Why did it take so long to abandon sail after steamships were demonstrated?

Did CPM support custom hardware using device drivers?

Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply

How to write cleanly even if my character uses expletive language?

Why are the outputs of printf and std::cout different

It's a yearly task, alright

Why do passenger jet manufacturers design their planes with stall prevention systems?

Ban on all campaign finance?

What is this large pipe coming out of my roof?

Is it true that real estate prices mainly go up?

What has been your most complicated TikZ drawing?

Sword in the Stone story where the sword was held in place by electromagnets

Can elves maintain concentration in a trance?

Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?

Can anyone tell me why this program fails?

How to generate globally unique ids for different tables of the same database?

Does the statement `int val = (++i > ++j) ? ++i : ++j;` invoke undefined behavior?

Have researchers managed to "reverse time"? If so, what does that mean for physics?

Identifying the interval from A♭ to D♯

Welcoming 2019 Pi day: How to draw the letter π?

PlotLabels with equations not expressions



Distance between a point and a MultiPolygon Geoseries object in python


Calculating distance between linestring and polygon with geopandasHow to get a Multipolygon object from Overpass QL?Unexpected intersects behavior between GeoSeries of Polygons and one of PointsFilter a GeoPandas dataframe for points within a specific countryGet distance between point and nearest polygonAlgorithm for Calculating Distance Between Two PointsCalculating distance between a Point and a MultiPolygon PostGIS objectPerform sjoin in geopandas leads to:'AttributeError: 'GeoSeries' object has no attribute 'columns''Getting error while importing GeoPandas in Python consoleHow to fix 'GeoSeries' object has no attribute '_geom'













0















I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code:



import numpy as np
import pandas as pd
import geopandas as gpd
from shapely.ops import cascaded_union
from matplotlib import pyplot as plt
from shapely.geometry import LineString, Point, MultiPoint

fp = "\TM_WORLD_BORDERS-0.3\TM_WORLD_BORDERS-0.3.shp"
data = gpd.read_file(fp)

mycountries = ['Canada','Russia']

req_data = data[data.NAME.isin(mycountries)]
req_data = req_data.reset_index()
req_data = req_data.drop('index',axis=1)

polygons = [req_data['geometry'][0],req_data['geometry'][1]]
boundary = gpd.GeoSeries(cascaded_union(polygons))
boundary.plot(color = 'black')
plt.show()


enter image description here



I require that when I calculate the distance of two points (as shown in map - red dots) from the multipolygon, it should consider Canada for the one in left side and Russia for the right one. Also, the distance in miles/kms. Any help around this will be really appreciated.



I tried using distance function but the result which I am getting is not correct. Moreover, if I consider point somewhere in Indian Ocean, it gives result as 0 which is again not what I require.



Please help me on this.
Thanks in advance!









share







New contributor




ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code:



    import numpy as np
    import pandas as pd
    import geopandas as gpd
    from shapely.ops import cascaded_union
    from matplotlib import pyplot as plt
    from shapely.geometry import LineString, Point, MultiPoint

    fp = "\TM_WORLD_BORDERS-0.3\TM_WORLD_BORDERS-0.3.shp"
    data = gpd.read_file(fp)

    mycountries = ['Canada','Russia']

    req_data = data[data.NAME.isin(mycountries)]
    req_data = req_data.reset_index()
    req_data = req_data.drop('index',axis=1)

    polygons = [req_data['geometry'][0],req_data['geometry'][1]]
    boundary = gpd.GeoSeries(cascaded_union(polygons))
    boundary.plot(color = 'black')
    plt.show()


    enter image description here



    I require that when I calculate the distance of two points (as shown in map - red dots) from the multipolygon, it should consider Canada for the one in left side and Russia for the right one. Also, the distance in miles/kms. Any help around this will be really appreciated.



    I tried using distance function but the result which I am getting is not correct. Moreover, if I consider point somewhere in Indian Ocean, it gives result as 0 which is again not what I require.



    Please help me on this.
    Thanks in advance!









    share







    New contributor




    ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code:



      import numpy as np
      import pandas as pd
      import geopandas as gpd
      from shapely.ops import cascaded_union
      from matplotlib import pyplot as plt
      from shapely.geometry import LineString, Point, MultiPoint

      fp = "\TM_WORLD_BORDERS-0.3\TM_WORLD_BORDERS-0.3.shp"
      data = gpd.read_file(fp)

      mycountries = ['Canada','Russia']

      req_data = data[data.NAME.isin(mycountries)]
      req_data = req_data.reset_index()
      req_data = req_data.drop('index',axis=1)

      polygons = [req_data['geometry'][0],req_data['geometry'][1]]
      boundary = gpd.GeoSeries(cascaded_union(polygons))
      boundary.plot(color = 'black')
      plt.show()


      enter image description here



      I require that when I calculate the distance of two points (as shown in map - red dots) from the multipolygon, it should consider Canada for the one in left side and Russia for the right one. Also, the distance in miles/kms. Any help around this will be really appreciated.



      I tried using distance function but the result which I am getting is not correct. Moreover, if I consider point somewhere in Indian Ocean, it gives result as 0 which is again not what I require.



      Please help me on this.
      Thanks in advance!









      share







      New contributor




      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code:



      import numpy as np
      import pandas as pd
      import geopandas as gpd
      from shapely.ops import cascaded_union
      from matplotlib import pyplot as plt
      from shapely.geometry import LineString, Point, MultiPoint

      fp = "\TM_WORLD_BORDERS-0.3\TM_WORLD_BORDERS-0.3.shp"
      data = gpd.read_file(fp)

      mycountries = ['Canada','Russia']

      req_data = data[data.NAME.isin(mycountries)]
      req_data = req_data.reset_index()
      req_data = req_data.drop('index',axis=1)

      polygons = [req_data['geometry'][0],req_data['geometry'][1]]
      boundary = gpd.GeoSeries(cascaded_union(polygons))
      boundary.plot(color = 'black')
      plt.show()


      enter image description here



      I require that when I calculate the distance of two points (as shown in map - red dots) from the multipolygon, it should consider Canada for the one in left side and Russia for the right one. Also, the distance in miles/kms. Any help around this will be really appreciated.



      I tried using distance function but the result which I am getting is not correct. Moreover, if I consider point somewhere in Indian Ocean, it gives result as 0 which is again not what I require.



      Please help me on this.
      Thanks in advance!







      python polygon distance shapely geopandas





      share







      New contributor




      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 mins ago









      ansmalansmal

      1




      1




      New contributor




      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      ansmal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          ansmal is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f315594%2fdistance-between-a-point-and-a-multipolygon-geoseries-object-in-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          ansmal is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          ansmal is a new contributor. Be nice, and check out our Code of Conduct.













          ansmal is a new contributor. Be nice, and check out our Code of Conduct.












          ansmal is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f315594%2fdistance-between-a-point-and-a-multipolygon-geoseries-object-in-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

          Meter-Bus Содержание Параметры шины | Стандартизация |...