geopy | Geocoding library for Python | REST library

 by   geopy Python Version: 2.3.0 License: MIT

kandi X-RAY | geopy Summary

kandi X-RAY | geopy Summary

geopy is a Python library typically used in Web Services, REST applications. geopy has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install geopy' or download it from GitHub, PyPI.

Geocoding library for Python.

            kandi-support Support

              geopy has a highly active ecosystem.
              It has 3956 star(s) with 612 fork(s). There are 93 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 25 open issues and 242 have been closed. On average issues are closed in 156 days. There are 12 open pull requests and 0 closed requests.
              It has a negative sentiment in the developer community.
              The latest version of geopy is 2.3.0

            kandi-Quality Quality

              geopy has 0 bugs and 0 code smells.

            kandi-Security Security

              geopy has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              geopy code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              geopy is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              geopy releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              geopy saves you 4416 person hours of effort in developing the same functionality from scratch.
              It has 9309 lines of code, 886 functions and 87 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed geopy and discovered the below as its top functions. This is intended to give you an instant insight into geopy implemented functionality, and help decide if they suit your requirements.
            • Geocode a query
            • Handle adapter errors
            • Parse the Retry - After header
            • Wrapper for geocoder
            • Perform geocode request
            • Format a degrees
            • Format the object as a string
            • Request raw content
            • Geocode a word
            • Call geocoding API
            • Geocoding API endpoint
            • Performs a reverse lookup
            • Parse an XML page
            • Reverse timezone query
            • Reverse a point
            • The geocode API endpoint
            • Parse geocoder response
            • Perform a geocoding query
            • Perform geocode
            • Perform geocoding
            • Geocode a location
            • Generate geocode coordinates
            • Reverse geocode query
            • Perform a reverse lookup
            • Reverse geocoder
            • Perform a reverse search
            Get all kandi verified functions for this library.

            geopy Key Features

            Geocoding library for Python.

            geopy Examples and Code Snippets

            Pythondot img1Lines of Code : 0dot img1License : Permissive (MIT)
            copy iconCopy
            pip install geopy  
            Pythondot img2Lines of Code : 0dot img2License : Permissive (MIT)
            copy iconCopy
            >>> from geopy.geocoders import Nominatim
            >>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
            >>> location = geolocator.geocode("175 5th Avenue NYC")
            >>> print(location.address)
            Flatiron Building, 1  
            Measuring Distance
            Pythondot img3Lines of Code : 0dot img3License : Permissive (MIT)
            copy iconCopy
            >>> from geopy.distance import geodesic
            >>> newport_ri = (41.49008, -71.312796)
            >>> cleveland_oh = (41.499498, -81.695391)
            >>> print(geodesic(newport_ri, cleveland_oh).miles)
            >>> from geopy.d  
            Get New GPS with Known start GPS, bearing and distance in feet
            Pythondot img4Lines of Code : 19dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import geopy
            import geopy.distance
            lat = 30.456025341663068
            lon = -86.41408883615411
            distance_ft = 86
            bearing = 0
            start_point = geopy.Point(lat, lon)
            end_point = geopy.distance.geodesic(feet=distance_ft).destination(start_point, bearing)
            Slicing a list item that exists in a pandas dataframe
            Pythondot img5Lines of Code : 4dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for i in split_dfs:
                i['Destination Coordinates'] = i['Destination Coordinates'].transform(
                    lambda x: x[:2] if isinstance(x, list) else x)
            Geopandas read geometry from geo_interface as JSON column in Dataframe
            Pythondot img6Lines of Code : 65dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from shapely.geometry import Point
            d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
            gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
            def flatten_nested_json_df(df):
                df = df.reset_ind
            Python/Django sorting a queryset by distance in REST framework
            Pythondot img7Lines of Code : 3dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            geocache_list_by_distance = sorted(geocache_list, key=operator.attrgetter('distance'))
                return geocache_list_by_distance
            Python - check if given zip code (or city) is in Czech Republic
            Pythondot img8Lines of Code : 10dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from geopy.geocoders import Nominatim
            geolocator = Nominatim(user_agent="geoapiExercises")
            location = geolocation.geocode('city-name')
            Brno, okres Brno-město, Jihomoravský kraj, Jihovýchod,
            Different data is being added to a file than is being printed in the console
            Pythondot img9Lines of Code : 5dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for element in distance_data_to_add:
                distance_data.write(str(element) + "\n")
            distance_data.write('\n'.join(map(repr, distance_to_add)))
            copy iconCopy
            from geopy import distance
            # slice the big area into small ones for Google map radius restriction problem
            def slice_search_area(point_a=(None, None), point_b=(None, None), region=None, radius=50000):
                if (None in point_a) or (None in 

            Community Discussions


            SSL Error (Port=443) Max retries exceeded when trying to import osmnx data in Jupiter Notebook
            Asked 2022-Mar-26 at 07:01

            When trying to run this line G = ox.graph_from_place('Piedmont, CA, USA', network_type='drive') I get this error:



            Answered 2022-Mar-26 at 07:01


            Adding new value through groupby operation using for cycle
            Asked 2022-Mar-18 at 17:40

            I need to add a column with changes ow worker coordinates through different stages. We have a DataFrame:



            Answered 2022-Mar-18 at 17:33

            I think that the problem could be the following line:



            Python get state district and state column for each lat long coordinate in Geopy
            Asked 2022-Feb-24 at 10:29

            I have a list of 200+ latitude and longitude coordinate pairs.

            For each coordinate pair I want to create a dataframe which contains column district and column state. So my dataframe will have 3 columns cord, district and state.

            For this I am using geopy library but I am unable to get record for more than 115 coordinates.

            Sample Data



            Answered 2022-Feb-24 at 10:29

            From Nominatim Usage Policy they require not to do heavy usage i.e. maximum 1 request per second. "No heavy uses (an absolute maximum of 1 request per second)." You can use geopy's RateLimiter to send 1 request per second. I've tested the following code works for more than 115 requests:



            Get New GPS with Known start GPS, bearing and distance in feet
            Asked 2022-Feb-16 at 16:11

            I am brand new to Python in general and have a limited but aged knowledge of Javascript. I am trying to accomplish a small project using Python, but I have gotten stuck with my own comprehension.

            I have a GPS coordinate in decimal degrees as a starting point (30.456025341663068, -86.41408883615411), a distance in feet (86 feet) from the start point to the expected endpoint and I have a bearing in degrees (0 to 360) from start point to endpoint. Given these values, I am attempting to simply return the GPS coordinate in decimal degrees of the endpoint.

            I found one StackExchange post that appears to give me a viable option using GeoPy, but I'm simply getting lost in trying to implement it. Can someone assist with how to accomplish this? GeoPy is not a requirement for me, I just imported it based on the answer in the other StackExchange question:

            calculating a gps coordinate given a point, bearing and distance



            Answered 2022-Feb-16 at 15:43

            Perhaps you could do something like this:



            How to create a column in Pandas with distance from coordinates using GeoPy
            Asked 2022-Feb-07 at 11:45

            I have this df:



            Answered 2022-Feb-07 at 11:45

            If you want to compare your df coordinates with some external coordinates tuple, try this:



            How to get the distance between two geographic coordinates of two different dataframes?
            Asked 2022-Feb-01 at 20:04

            I am working on a project for university, where I have two pandas dataframes:



            Answered 2022-Feb-01 at 13:32

            You can cross-merge the two dfs to get a distance between each id in df1 vs df2:



            Python/Django sorting a queryset by distance in REST framework
            Asked 2022-Jan-02 at 23:58

            Currently, I am adding a field, 'distance', to a queryset after it's been created, and then returning it. However, I would like to sort the queryset by distance, if it's possible to annotate it.

            Currently, my model, GeoCache, has fields latitude and longitude as models.DecimalField(max_digits=15, decimal_places=10, null=True, blank=True). Using geopy, I can add distance to my queryset like this:



            Answered 2022-Jan-02 at 23:58

            Thanks to the comment from Andre Borie, I decided to focus on sorting the queryset after-the-fact, and fixed it with this:



            Pyspark - Map and apply calculation using value from dictionaries
            Asked 2021-Dec-20 at 15:03

            I have two dictionaries. One where UserID is the key and their location is the value. The first items look like this:



            Answered 2021-Dec-20 at 15:03

            You can create RDDs from the users_dict and places_dict then join with ratings_rdd to get the coordinates of the user and the rated place. Then using map, call geodesic to calculate the distance.

            Here's an example:



            Calculate the geographical distance in pyspark dataframe
            Asked 2021-Dec-11 at 13:18

            My dataframe:



            Answered 2021-Dec-11 at 13:15


            Find Minimum number of Circles with 50-Mile Radius that Covers All Points
            Asked 2021-Nov-22 at 00:09

            Given a list of lat/lon points, how can we find the minimum number of 50-mile radius circles (and their lat/lon points) such that these circles cover all the points in the list?

            The solution does not need to be optimal, and the calculation of radiuses/distances can be approximated, for simplicity. Or use a helper library like geopy.distance.

            For example, here is a CSV list of lat/lon points:



            Answered 2021-Nov-22 at 00:09

            Updated answer based on comments:

            You have many options.

            Here are 3 differents ways of doing that:

            1. With scipy.CKDTree:

            Pros :

            • This will be fast

            Cons :

            • less accurate because the computed distance is euclidean
            • and the radius will be the same as your inputs, so here in degrees

            I would go with a cKDTree and a radius query to find all points in radius, remove theses points from list, and continue with remaining points. This is not optimal but can be a good basis.


            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install geopy

            You can install using 'pip install geopy' or download it from GitHub, PyPI.
            You can use geopy like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • PyPI

            pip install geopy

          • CLONE
          • HTTPS


          • CLI

            gh repo clone geopy/geopy

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link