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
112
votes
16 answers

Error installing geopandas:" A GDAL API version must be specified " in Anaconda

This error raised while installing geopandas. I've looking for its solution on the web, but none of them really explain what happened and how to solve it.. This is the full error: Collecting geopandas Using cached…
Alvaro Morales
  • 1,845
  • 3
  • 12
  • 21
78
votes
3 answers

Make a union of polygons in GeoPandas, or Shapely (into a single geometry)

I am trying to find the union of two polygons in GeoPandas and output a single geometry that encompasses points from both polygons as its vertices. The geopandas.overlay function gives me polygons for each individual union but I would like a single…
p-robot
  • 4,652
  • 2
  • 29
  • 38
53
votes
2 answers

GeoPandas Label Polygons

Given the shape file available here: I'd like to label each polygon (county) in the map. Is this possible with GeoPandas? import geopandas as gpd import matplotlib.pyplot as plt %matplotlib inline shpfile=
Dance Party2
  • 7,214
  • 17
  • 59
  • 106
41
votes
1 answer

Converting a geopandas geodataframe into a pandas dataframe

What is the most efficient way to convert a geopandas geodataframe into a pandas dataframe? Below is the method I use, is there another method which is more efficient or better in general at not generating errors? import geopandas as gpd import…
jberrio
  • 972
  • 2
  • 9
  • 20
39
votes
17 answers

how to successfully install pyproj and geopandas?

I have tried to install geopandas via I python by running !pip install geopandas, but this fails with "python setup.py egg_info" failed with error code 1 and then Path to long directory. I read online that pyproj is required for geopandas and also…
user3144095
  • 491
  • 1
  • 4
  • 3
36
votes
3 answers

GeoPandas Set CRS on Points

Given the following GeoDataFrame: h=pd.DataFrame({'zip':[19152,19047], 'Lat':[40.058841,40.202162], 'Lon':[-75.042164,-74.924594]}) crs='none' geometry = [Point(xy) for xy in zip(h.Lon, h.Lat)] hg = GeoDataFrame(h,…
Dance Party2
  • 7,214
  • 17
  • 59
  • 106
34
votes
8 answers

Convert geopandas shapely polygon to geojson

I created a circle using geopandas and it returned a shapely polygon: POLYGON: ((...)) I want this same polygon as a geojson object. I ran across this: shapely.geometry.mapping(shapelyObject) which returns this: {'type': 'Polygon', 'coordinates':…
conv3d
  • 2,668
  • 6
  • 25
  • 45
33
votes
1 answer

geopandas point in polygon

I have a GeoDataFrame of polygons (~30) and a GeoDataFrame of Points (~10k) I'm looking to create 30 new columns (with appropriate polygon names) in my GeoDataFrame of Points with a simple boolean True/False if the point is present in the…
Kvothe
  • 1,341
  • 7
  • 20
  • 33
32
votes
1 answer

Which geopandas datasets (maps) are available?

I just created a very simple geopandas example (see below). It works, but I noticed that it is important for me to be able to have a custom part of the world. Sometimes Germany and sometimes only Berlin. (Also, I want to aggregate the data I have by…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
31
votes
4 answers

Geopandas: how to read a csv and convert to a geopandas dataframe with polygons?

I read a .csv file as a dataframe that looks like the following: import pandas as pd df = pd.read_csv('myFile.csv') df.head() BoroName geometry 0 Brooklyn MULTIPOLYGON (((-73.97604935657381 40.63127590... 1 Queens MULTIPOLYGON…
emax
  • 6,965
  • 19
  • 74
  • 141
29
votes
3 answers

Shapely point geometry in geopandas df to lat/lon columns

I have a geopandas df with a column of shapely point objects. I want to extract the coordinate (lat/lon) from the shapely point objects to generate latitude and longitude columns. There must be an easy way to do this, but I cannot figure it out. I…
jtam
  • 814
  • 1
  • 8
  • 24
28
votes
1 answer

Converting a column of Polygons from string to GeoPandas geometry

I have a dataframe stored as csv file, one column of which is Polygon object. However, this column is stored as strings instead of GeoPandas geometry object. How can I convert this column to Geopandas geometry object so that I can perform geo…
xinyuanliu
  • 395
  • 1
  • 3
  • 5
25
votes
4 answers

Loading JSON into a GeoDataFrame

I'm having difficulty loading the following JSON containing GIS data (https://data.cityofnewyork.us/resource/5rqd-h5ci.json) into a GeoDataFrame. The following code fails when I try to set the geometry. import requests import geopandas as gpd data =…
blahblahblah
  • 2,299
  • 8
  • 45
  • 60
23
votes
4 answers

why can't I import geopandas?

My only line of code is import geopandas and it gives me the error OSError: Could not find libspatialindex_c library file has anyone encountered this before? my script was working just fine until this error came up. **Note that rtree module not…
jrowley
  • 347
  • 2
  • 6
20
votes
3 answers

Relocating legend from GeoPandas plot

I'm plotting a map with legends using the GeoPandas plotting function. When I plot, my legends appear in the upper right corner of the figure. Here is how it looks like: I wanted to move the legends to the lower part of the graph. I would normally…
josecoto
  • 732
  • 1
  • 7
  • 15
1
2 3
99 100