Questions tagged [geopandas]

GeoPandas is an open source project to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types.

GeoPandas is an open source project to make working with geospatial data in python easier. GeoPandas extends the datatypes used by pandas to allow spatial operations on geometric types.

Geometric operations are performed by shapely. Geopandas further depends on fiona for file access and descartes and matplotlib for plotting.

If you're having trouble running or installing geopandas, it is recommended that you use conda to install geopandas into a new conda environment. When installing the GIS stack, it's recommended that you pull all of the dependencies from a single channel (e.g., only from the default channel or only from conda-forge):

> conda create --name=gis python=3.7 geopandas --channel=conda-forge

Resources:

2652 questions
15
votes
1 answer

Intersection of Two LineStrings Geopandas

Let's say I have the following to GeoDataFrames of linestrings, one of which represents roads and one of which represents contour lines. >>> import geopandas as gpd >>> import geopandas.tools >>> import shapely >>> from shapely.geometry import * >>>…
AJG519
  • 3,249
  • 10
  • 36
  • 62
14
votes
1 answer

Convert Geopandas Multipolygon to Polygon

I have a geodataframe with a Multipolygon geometry: I would like to convert them to Polygons i.e. fill in the holes of multipolygon and make it a single polygon. I have tried the code from this similar question: from shapely.geometry import…
SCool
  • 3,104
  • 4
  • 21
  • 49
14
votes
3 answers

Conda install some-package hangs with (Solving environment: failed)

I have tried multiple ways but can't conda install packages (in my case, geopandas). I tried geopandas install guide, but get output that the solver runs forever. I tried without creating an environment, after creating a new environment, using…
SadHak
  • 367
  • 1
  • 2
  • 9
14
votes
6 answers

Can't install geopandas in Anaconda environment

I am trying to install the geopandas package with Anaconda Prompt, but after I use conda install geopandas an unexpected thing happened: Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve.…
14
votes
3 answers

Get the nearest distance with two geodataframe in pandas

Here is my first geodatframe : !pip install geopandas import pandas as pd import geopandas city1 = [{'City':"Buenos Aires","Country":"Argentina","Latitude":-34.58,"Longitude":-58.66}, …
Bussiere
  • 500
  • 13
  • 60
  • 119
14
votes
3 answers

Concat multiple shapefiles via geopandas

I'm trying to combine multiple shapefiles by implementing the follwing: import geopandas as gpd import pandas as pd for i in range(10,56): interesting_files = "/Users/m3105/Downloads/area/tl_2015_{}_arealm.shp".format(i) gdf_list = [] …
M3105
  • 519
  • 2
  • 7
  • 20
13
votes
1 answer

Can geopandas get a geopackage's (or other vector file) all layers?

I want to use geopandas read a geopackage file, It can read the first layer or specific layer with layer='' parameter. But how can it read all layers? May be like: all_layers = gp.read_xxxx('xxx.gpkg') for layer in layers: # fetch this layer
wsf1990
  • 195
  • 2
  • 12
13
votes
2 answers

Geopandas reduce legend size (and remove white space below map)

I would like to know how to change the legend automatically generated by Geopandas. Mostly I would like to reduce its size because it's quite big on the generated image. The legend seems to take all the available space. Additional question, do you…
Arnaud Geotribu
  • 919
  • 4
  • 11
  • 22
13
votes
1 answer

Geopandas add labels to points on plot

I have a geodataframe 'all_locations' with a geometry column and a column with the name of the point. Plotting the points on a map works just fine but I want to annotate the points with location name. ['location'] ['geometry'] BUITHVN8 …
J-man
  • 261
  • 1
  • 3
  • 10
13
votes
1 answer

Plot the Geometry of one row of a GeoDataFrame

I would like to plot the geometry contained in a single row of a geopandas dataframe, but I am having problems. Here an example import geopandas as gpd import numpy as np from shapely.geometry import Polygon p1 = Polygon([(0, 0), (1, 0), (1,…
Duccio Piovani
  • 1,410
  • 2
  • 15
  • 27
12
votes
1 answer

Plotly: How to set choropleth map color for a discrete categorical variable?

I am trying to plot a world map with all the countries having different risk levels (low, moderate and high). I would like to make each risk level a different color but am not sure how to change the color scheme so that each risk category has a…
Sanch
  • 367
  • 2
  • 11
12
votes
3 answers

Change background map for contextily

I have this code: import pandas as pd import numpy as np from geopandas import GeoDataFrame import geopandas from shapely.geometry import LineString, Point import matplotlib.pyplot as plt import contextily ''' Do Something''' df =…
12
votes
2 answers

Overly Function from GeoPandas Not Working

I simply want to use geopandas to get a union and intersection of two polygonal areas. I define: import geopandas as gpd from shapely.geometry import Polygon polys1 = gpd.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]), …
Rotail
  • 1,025
  • 4
  • 19
  • 40
12
votes
3 answers

What is the most efficient way to convert numpy arrays to Shapely Points?

I have a function that outputs a grid of points as x and y numpy arrays for interpolation, but before I interpolate, I want to use Geopandas to perform an intersection with my research boundary (otherwise half of my interpolation points fall in the…
Ryan
  • 1,032
  • 1
  • 10
  • 23
11
votes
1 answer

How do I test if Point is in Polygon/Multipolygon with geopandas in Python?

I have the Polygon data from the States from the USA from the website arcgis and I also have an excel file with coordinates of citys. I have converted the coordinates to geometry data (Points). Now I want to test if the Points are in the…
Kamel
  • 141
  • 1
  • 9