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
9
votes
1 answer

Zooming and saving only a central part of interest in a matplotlib geopandas figure

I plot a map using geopandas and colormap with the code: import numpy as np ## make up some random data df = pd.DataFrame(np.random.rand(20, 3), columns=['x', 'y', 'val']) df['geometry'] = df.apply(lambda row: shapely.geometry.Point(row.x, row.y),…
B Furtado
  • 1,488
  • 3
  • 20
  • 34
9
votes
3 answers

Enhance performance of geopandas overlay(intersection)

I have two sets of shapefiles with polygons. One set of shapefile is just the US counties I'm interested in and this varies across firms and years. The other set of shapefile is the business area of firms and of course this varies across firms and…
Crystie
  • 385
  • 6
  • 12
9
votes
2 answers

Geopandas Dataframe Points to Polygons

I have a geopandas dataframe made up of an id and a geometry column which is populated by 2D points. I want to join the points for each unique id to create a polygon, so that my new dataframe will have polygons as its geometry. My code currently…
GSam11
  • 101
  • 1
  • 1
  • 7
8
votes
2 answers

AttributeError: 'NoneType' object has no attribute 'drvsupport' when using Fiona driver

when I run the following code: import geopandas as gpd from shapely.geometry import Point, Polygon import pandas as pd gpd.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw' my_map = gpd.read_file('mymap.kml', driver='KML') my_map I get…
S J
  • 133
  • 2
  • 7
8
votes
1 answer

How to display markers at specific zoom levels?

I was able to display a marker for each part of geography for the USA data (using US data as an example since can't display the work data results) using below: import dload from shapely.geometry import shape import geopandas as gpd import pandas as…
Isaac A
  • 543
  • 1
  • 6
  • 18
8
votes
1 answer

How to apply different border widths for subregions in python geopandas choropleth map

I am making choropleth maps with geopandas. I want to draw maps with two layers of borders: thinner ones for national states (geopandas default), and thicker ones for various economic communities. Is this doable in geopandas? Here is an…
Antti
  • 1,263
  • 2
  • 16
  • 28
8
votes
1 answer

How to change the crs of a raster with rasterio?

I am trying to change the CRS of a raster tif file. When I assign new CRS using the following code: with rio.open(solar_path, mode='r+') as raster: raster.crs = rio.crs.CRS({'init': 'epsg:27700'}) show((raster, 1)) print(raster.crs) The…
four_loops
  • 235
  • 1
  • 2
  • 9
8
votes
1 answer

Is it bad practice to have more than 1 geometry column in a GeoDataFrame?

I'm trying to create a GeoDataFrame with 2 zip codes per row, whose distances from each other I want to compare. I took a list of approx 220 zip codes and ran an itertools combination on them to get all combo's, then unpacked the tuples into two…
var.ela
  • 93
  • 1
  • 5
8
votes
3 answers

geodataframe.to_file Invalid field type

I am processing shp files, and i'm having problems saving a geodataframe in a shp file. import pandas as pd import numpy as np import os import geopandas location = '/home/braulio/Documents/example.shp' datos = geopandas.read_file(location,…
8
votes
4 answers

b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' geopandas python

I am trying to read in a shapefile into a GeoDataFrame. Normally I just do this and it works: import pandas as pd import geopandas as gpd from shapely.geometry import Point df = gpd.read_file("wild_fires/nbac_2016_r2_20170707_1114.shp") But…
Julien
  • 992
  • 1
  • 10
  • 26
8
votes
1 answer

GeoPandas, MatPlotLib Plot Custom Colors

Given the shape file available here: I'd like to plot the specified set of counties below with custom colors; 'blue' for Wayne and Washtenaw counties and 'grey' for the others. import geopandas as gpd import matplotlib.pyplot as plt %matplotlib…
Dance Party2
  • 7,214
  • 17
  • 59
  • 106
8
votes
2 answers

Convert GeoDataFrame polygons to kml file

I have a geopandas GeoDataFrame with various polygons and colors that I'm using to plot meteorological data (another question I asked here): color geometry 0 #fbfdd1 (POLYGON ((-97.12191717810094 32.569, -97.1194... 1 #f3fabf (POLYGON…
edub
  • 659
  • 4
  • 8
  • 19
8
votes
4 answers

Shapely Split LineStrings at Intersections with other LineStrings

I have a set of LineStrings which are intersected by other LineStrings and I want to split the LineString into separate segments at these intersection points. I have a solution but I don't think it's the best approach. Let's say we are dealing with…
AJG519
  • 3,249
  • 10
  • 36
  • 62
8
votes
1 answer

Identify unique groupings of polygons in Geopandas / Shapely

Let's say I have two disjoint groups / "islands" of polygons (think census tracts in two non-adjacent counties). My data could look something like this: >>> p1=Polygon([(0,0),(10,0),(10,10),(0,10)]) >>>…
AJG519
  • 3,249
  • 10
  • 36
  • 62
7
votes
3 answers

The indices of the two GeoSeries are different - Understanding Indices

I am working with GeoPandas and I have two GeoDataframes with the same CRS. One of them contains a geometry column with a polygon geometry, the other one a column with point geometry. I want to check which points are inside the polygon. Naively I…
four-eyes
  • 10,740
  • 29
  • 111
  • 220