geopandas | Python tools for geographic data | Map library

 by   geopandas Python Version: 1.0.0a1 License: BSD-3-Clause

kandi X-RAY | geopandas Summary

kandi X-RAY | geopandas Summary

geopandas is a Python library typically used in Geo, Map applications. geopandas 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 geopandas' or download it from GitHub, PyPI.

GeoPandas [Join the chat at

            kandi-support Support

              geopandas has a highly active ecosystem.
              It has 3705 star(s) with 826 fork(s). There are 107 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 338 open issues and 1116 have been closed. On average issues are closed in 264 days. There are 81 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of geopandas is 1.0.0a1

            kandi-Quality Quality

              geopandas has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              geopandas is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              geopandas releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              geopandas saves you 7215 person hours of effort in developing the same functionality from scratch.
              It has 19452 lines of code, 1522 functions and 82 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed geopandas and discovered the below as its top functions. This is intended to give you an instant insight into geopandas implemented functionality, and help decide if they suit your requirements.
            • Returns a dict containing the cmdclass for the given cmdclass
            • Deprecated
            • Read a file
            • Create a Config object from a root
            • Return whether this sequence contains other
            • Helper function for binary operations
            • Delegate a binary method
            • Read data from Parquet
            • Import an optional module
            • Project this vector onto another
            • Return the disjoint of two sets
            • Return whether this array is within the given range
            • Create a GeoDataCollection from a feature collection
            • Create a versioneer config file
            • Transform the geometries to a CRS
            • Create a GeoDataFrame from a postgis query
            • Estimate UTM CRS
            • Return True if this element is touching other
            • Calculate the relationship between two vectors
            • Set the CRS of the GeoSeries
            • Return True if self intersects with self
            • Return whether this range overlaps with another
            • Return whether this interval covers the other
            • Return the cross product of two vectors
            • Returns whether this range covers the other
            • Compute the distance between two sequences
            Get all kandi verified functions for this library.

            geopandas Key Features

            No Key Features are available at this moment for geopandas.

            geopandas Examples and Code Snippets

            Geopandas way of removing child geometries
            Pythondot img1Lines of Code : 10dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import numpy
            import geopandas
            import pandas
            pts = geopandas.GeoSeries.from_xy(x=numpy.random.randint(0, 100, 50), y=numpy.random.randint(0, 100, 50))
            # create polygons that are one within the other
            geoms = pd.concat([pts.buffer(1), pts.bu
            Geopandas: different .sjoin() results with different projections systems
            Pythondot img2Lines of Code : 53dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            test = ["Unit 1", "Unit 2"]
            test_lat = ["0.176095", "-24.193790"]
            test_lon = ["117.495523", "150.370650"]
            df = pd.DataFrame()
            df["Name"] = test
            df["Latitude"] = test_lat
            df["Longitude"] = test_lon
            gdf = gpd.GeoDataFrame(df, geometry=gpd.
            Plotly choropleth_mapbox doesn't show map when parsing animation_frame=""
            Pythondot img3Lines of Code : 59dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import as px
            Defined_M_rob_data = (
                df.groupby(["EER13CD", "month"], as_index=False)
                .rename(columns={"size": "Crime count", "month": "Month"})
            merged = gdf.set_index("EER13CD")
            fig = px.choropleth_map
            Python: Masking ERA5 data (NetCDF) from shapefile (polygon/multipolygon)
            Pythondot img4Lines of Code : 17dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import geopandas as gpd
            import xarray as xr
            import rioxarray
            from shapely.geometry import mapping
            # load shapefile with geopandas
            radar_north = gpd.read_file('radar_north140.shp')
            # load ERA5 netcdf with xarray
            era = xr.open_dataset('ERA
            Issue reproducing "Create a kml in python that has both points and lines" post
            Pythondot img5Lines of Code : 19dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import geopandas as gpd
            import simplekml
            kml = simplekml.Kml()
            df = gpd.read_file("C:/Users/CombineKMLs_AddLabels/Data/ScopePoles.shp")
            points = []
            for index, poi in df.iterrows():
              pt = df.loc[index, 'geometry']
              coord = (pt.x, pt.y)
            Choropleth heat map missing some area
            Pythondot img6Lines of Code : 28dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import geopandas as gpd
            import pandas as pd
            import as px
            gdf = gpd.read_file(
            sellers = pd.read_csv(
            How to plot a .SHP file with Plotly go.Choroplethmapbox()?
            Pythondot img7Lines of Code : 92dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import requests
            from pathlib import Path
            from zipfile import ZipFile
            import geopandas as gpd
            import numpy as np
            import plotly.graph_objects as go
            import json
            # get the shape file...
            url = "
            GeoDataFrame Value Error: 'data' should be a 1-dimensional array of geometry objects'
            Pythondot img8Lines of Code : 69dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import osmnx as ox
            import geopandas as gpd
            import pandas as pd
            import io
            df = pd.read_csv(
            Pandas/Geopandas Merge with a mask selection
            Pythondot img9Lines of Code : 30dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            al_merge = al_gdf.merge(al_gdf, sel_df, left_on="Location", right_on="sketch_LOC")
            import pandas as pd
            import numpy as np
            import geopandas as gpd
            # synthesize
            svc_df = pd.DataFrame(
                    "createdate": pd.
            Geopandas plot makes label for every datapoint instead of a colorbar
            Pythondot img10Lines of Code : 16dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import geopandas as gpd
            import numpy as np
            gdf_MA_outage = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")).loc[
                lambda d: (d["continent"] == "Europe") & (~d["iso_a3"].isin(["-99", "RUS"]))

            Community Discussions


            Faster methods to create geodataframe from a Dask or Pandas dataframe
            Asked 2022-Mar-31 at 20:54


            I'm trying to clip a very large block model (5.8gb CSV file) containing centroid x, y, and z coordinates with an elevation raster. I'm trying to obtain only the blocks lying just above the raster layer.

            I usually do this in ArcGIS by clipping my block model points to the outline of my raster and then extracting the raster values to the block model points. For large datasets this takes an ungodly amount of time (yes, that's a technical term) in ArcGIS.

            How I want to solve it

            I want to speed this up by importing the CSV to Python. Using Dask, this is quick and easy:



            Answered 2022-Mar-31 at 20:54

            The optimal way of linking dask and geopandas is the dask-geopandas package.



            pip uninstall GDAL gives AttributeError: 'PathMetadata' object has no attribute 'isdir'
            Asked 2022-Mar-10 at 01:12

            I'm trying to pip install geopandas as a fresh installation, so I want to remove existing packages like GDAL and fiona. I've already managed to pip uninstall fiona, but when I try to uninstall or reinstall GDAL it gives the following error message:



            Answered 2022-Mar-10 at 01:12

            I just came across this question after getting the same error. Coincidentally I had just upgraded pip (I was getting tired of the yellow warnings).

            All I had was to down grade my pip



            Rearranging polygons in geopandas for matplotlib plotting
            Asked 2022-Mar-08 at 20:20

            I am working on a project where I am using a shape file to make a choropleth map of the United States. To do this, I downloaded the standard shape file here from the US Census Bureau. After a little bit of cleaning up (there were some extraneous island territories which I removed by changing the plot's axis limits), I was able to get the contiguous states to fit neatly within the bounds of the matplotlib figure. For reference, please see Edit 4 below.

            Edit 1: I am using the [3.2 MB] shape file.

            The only problem now is that by setting axis limits I now am no longer able to view Alaska and Hawaii (as these are obviously cut out by restricting the axis limits). I would now like to add both of these polygons back in my map but now towards the lower part of the plot figure (the treatment that is given by most other maps of this type) despite its geographical inaccuracy.

            To put this more concretely, I am interested in selecting the polygon shapes representing Alaska and Hawaii and moving them to the lower left hand side of my figure. Is this something that would be possible?

            I can create a Boolean mask using:



            Answered 2021-Sep-22 at 17:25

            You could do something like this. You will have to find the right offsets to position Alaska where you want it to be exactly.

            Now, you have the following dataframe:



            Joining rows from two dataframes with the closest point
            Asked 2022-Feb-23 at 12:17

            Hi I am kinda new to spark and I am not sure how to approach this.

            I have 2 tables (way smaller for easier explanation):

            A:Weather Data

            B:travel data

            I need to join these tables by finding the closest station when the trip started in the same date and do the same when the trip ended. so at the end I have all the weather data from the station at the time the trip started and when the trip finished, and just one row for each trip with the data from the closest weather station.

            i have done something similar with geopandas and udf but it was way easier because i was looking for an interception. like this:



            Answered 2022-Feb-23 at 12:17

            I changed your sample data a bit because all stations have the same coordinates:



            When do I need to use a GeoSeries when creating a GeoDataFrame, and when is a list enough?
            Asked 2022-Feb-05 at 22:11
            import geopandas as gpd
            import matplotlib.pyplot as plt
            from shapely.geometry import Polygon, Point
            import numpy as np


            Answered 2022-Feb-05 at 22:11

            On the docs for geopandas.GeoDataFrame, where you got your example, there's a little note:

            Notice that the inferred dtype of ‘geometry’ columns is geometry.

            Which can be seen here, and you can observe it yourself:



            How to convert coordinates for use in GeoPandas? (e.g., 37_N)
            Asked 2022-Jan-25 at 00:44

            I have the following dataframe:



            Answered 2022-Jan-25 at 00:44

            You would need to map your values into a range between -180 and 180 both for longitude and latitude. Here the geopandas documentation

            Here is a function that does that.



            Removing intersecting lines in geopandas
            Asked 2022-Jan-13 at 19:04

            I have a large geodataframe (potentially millions of rows) which consists of LineString geometries. Some of these lines could intersect each other, whereas others don't intersect. I would like to remove all lines that intersect in an efficient manner. I have a solution using "apply" and a shapely function to find intersections, but it is very slow on large datasets. Any help would be much appreciated!

            My solution so far with a small example geodataframe is below. This works but is slow when scaled up.



            Answered 2022-Jan-13 at 19:04

            How about a spatial join that will utilize a built-in R-tree spatial index?



            Read SHP file from SFTP using pysftp
            Asked 2022-Jan-03 at 07:35

            I am trying to use pysftp's getfo() to read a shapefile (without downloading it). However the output I get does not seem workable and I'm not sure if its possible do this with a shapefile.

            Ideally I would like to read in the file and convert it to a Geopandas GeoDataFrame.



            Answered 2021-Dec-28 at 07:45

            Something like this should do:



            Plotting polygons with Folium and Geopandas don't work
            Asked 2021-Dec-25 at 22:21

            I have tried to plot polygons to map with Geopandas and Folium using Geopandas official tutorial and this dataset. I tried to follow the tutorial as literally as I could but still Folium don't draw polygons. Matplotlib map works and I can create Folium map too. Code:



            Answered 2021-Dec-25 at 22:21

            The trick here is to realize that your data is not in units of degrees. You can determine this by looking at the centroid of your polygons:



            Unable to draw choropleth data on folium map with Zip Code laid out
            Asked 2021-Dec-03 at 05:08

            My Data is just a simple csv with a Zip Code column with an Uninsured Column to represent the percentage of uninsured population in that zip code. Also the geojson file for the zip codes is attached here



            My Code is as follows:



            Answered 2021-Dec-03 at 05:08

            The reason you could not draw the graph may be that the geometry of geopandas is a line segment. I got the zip code geojson file from here to deal with this. This file is in polygon format. Also, if you reference it as it is in goepandas, the key referenced in key_on will be 'feature.propeties.zipcode'. One important point is that the zip code to be associated with geojson is a string, so the user data must also be a string.


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


            No vulnerabilities reported

            Install geopandas

            You can install using 'pip install geopandas' or download it from GitHub, PyPI.
            You can use geopandas 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 geopandas

          • CLONE
          • HTTPS


          • CLI

            gh repo clone geopandas/geopandas

          • 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