Questions tagged [geopandas]

GeoPandas is an open source project to make working with geospatial data in python easier.

Filter by
Sorted by
Tagged with
12
votes
3answers
10k views

Dissolving polygons based on attributes with Python (shapely, fiona)?

I have been trying to create a function that does basically the same thing that the QGIS "dissolve" function. I thought it would be super easy but well apparently not. So from what I have gathered ...
16
votes
4answers
13k views

GeoPandas: Find nearest point in other dataframe

I've got 2 geodataframes: import geopandas as gpd from shapely.geometry import Point gpd1 = gpd.GeoDataFrame([['John',1,Point(1,1)],['Smith',1,Point(2,2)],['Soap',1,Point(0,2)]],columns=['Name','ID','...
10
votes
3answers
7k views

What units are used by GeoPandas/Shapely area and distance functions?

it looks like a silly question, yet I can't find clear answer on that: what units geopandas/shapely use calculating distance/area between objects?
10
votes
1answer
7k views

GeoPandas to_file() saves GeoDataFrame without coordinate system

I have GeoPandas 0.2.1 py27_0 fiona 1.7.0 np110py27_1 Python 2.7.10 installed in Anaconda 2-4.1.1-Windows-x86 environment. I am able to construct GeoDataFrame by reading input datasets and ...
5
votes
1answer
6k views

Split lines at points using Shapely

I'm trying to split a shapefile of geometry type 'line' at a shapefile of geometry type 'point. These points are snapped to the lines and are the start points/end points of other line shapefiles. ...
38
votes
2answers
33k views

Convert a pandas DataFrame to a GeoDataFrame

This seems like a simple enough question, but I can't figure out how to convert a pandas DataFrame to a GeoDataFrame for a spatial join. Here is an example of what my data looks like using df.head(): ...
12
votes
3answers
6k views

geopandas spatial join extremely slow

I am using the code below to find a country (and sometimes state) for millions of GPS points. The code currently takes about one second per point, which is incredibly slow. The shapefile is 6 MB. I ...
7
votes
1answer
4k views

Plot shapefile on top of raster using plot and imshow from matplotlib

I need to plot a shapefile on top of a raster. I would like to use the python package rasterio and some combination of fiona or geopandas to load the shapefile. I found an example in the rasterio ...
3
votes
1answer
6k views

Intersecting two shape problem using geopandas

I'm trying to intersect two polygons based on the following link, intersecting two shapefiles from Python or command line But problem occured that shows a "ValueError: Geometry column cannot contain ...
2
votes
1answer
3k views

Geopandas/folium map not displaying?

I'm trying to use a combination of geopandas, pandas and folium to create a polygon map that I can embed incorporate into a web page. For some reason, it's not displaying and wonder if anyone can ...
6
votes
1answer
6k views

Geopandas buffer using geodataframe while maintaining the dataframe

The objective is to create a geoDataFrame with buffered geometries AND with all the "attributes" of the original geodataframe. I am able to perform a buffer on my geoDataFrame using: gdfHybasBuffer ...
3
votes
1answer
113 views

geopandas.intersects() over each row

In trying to answer Writing selected features to shapefile using OGR and Python? I ran into problems with geopandas.GeoSeries intersects methods. I have the following line and polygon: import pandas ...
1
vote
3answers
8k views

Only read specific attribute columns of a shapefile with Geopandas / Fiona

Having geopandas installed in my Python environment, I can read a shapefile into a geodataframe with In: import geopandas as gpd myShapefile = gpd.read_file(path_to_my_shapefile) print(myShapefile) ...
1
vote
0answers
143 views

Why is Union in ArcMap much faster than other approaches? [closed]

Taking the union* of these two large shapefiles file1 file2 locally using ArcMap takes appr. 10 min. Over the last few weeks, I've tried to obtain the same results using other, open-source ...
1
vote
2answers
2k views

How to list all polygon vertice coordinates using geopandas

Im trying to list all polygon vertice coordinates of a rectangle with four corners and a hole with four corners. I drew the vertices in this order: import geopandas as gpd import matplotlib.pyplot as ...
5
votes
2answers
2k views

Find all neighbors using geopandas

I am wondering whether it is possible to identify all neighbors to each polygon using only python (with, e.g., geopandas) in the same way that can be done with python in QGIS (Find neighbors polygon).
11
votes
2answers
6k views

Adding GeoPandas Dataframe to PostGIS table?

I have a simple GeoPandas Dataframe: I would like to upload this GeoDataframe to a PostGIS table. I have a Database setup with the PostGIS extension already but can't seem to add this Dataframe as a ...
7
votes
1answer
7k views

Rasterize a shapefile with Geopandas or fiona - python

I need to rasterize a really simple shapefile a bit like this http://tinyurl.com/odfbanu. Which is just a shapefile coutaining counties in the US.I have seen this previous answer : GDAL RasterizeLayer ...
5
votes
1answer
3k views

How do I convert Eastings and Northings projection to WSG84 in geopandas?

I'm very new to projections and struggling to convert a map dataset from OSGB36 (Eastings and Northings) to WGS84 (lat/longs). I've used geopandas to import a shapefile. Now I want to export it as ...
8
votes
1answer
9k views

Turning GeoDataFrame of x,y coordinates into Linestrings using GROUPBY?

I have a dataframe of X,Y coordinates that represent points along the paths taken by several different entities. Pseudo-data here, but it is roughly of the form: entity_id lat lon time 1001 ...
6
votes
3answers
10k views

Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'

I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices. The problem is that ...
5
votes
1answer
1k views

Speed up row-wise point in polygon with Geopandas

I have a geopandas GeoDataframe which contains some attributes and a geometry column which is filled with shapely Point(lon, lat) objects. Moreover, there is a GeoSeries which is equally indexed as ...
4
votes
1answer
9k views

How to extract long and lat from geometry column in GeoPandas?

I read a shapefile with GeoPandas and I get a nice table with a column "geometry". This column contains shapely.geometry.polygon.Polygon or shapely.geometry.multipolygon.MultiPolygon object. import ...
4
votes
1answer
2k views

Reading the names of geodatabase file layers in Python

I'm looking at New York City's Projected Sea Level Rise dataset. This dataset states that it is: Geodatabase of projected sea level rise based on models released by New York City Panel on Climate ...
4
votes
1answer
2k views

Insert Geopandas GeoDataFrame into Spatialite database

Is it possible to insert a Geopandas GeoDataFrame directly into a Spatialite database with Python so that the geometry column of the GeoDataFrame becomes a proper geometry table in the database which ...
2
votes
1answer
5k views

How to select features where column matches a regex and save them in a new shapefile?

I want to select features from a shapefile where the value of column matches a regex then save only the selected features in a new shapefile.(I used regex101.com to write the regex and check if it's ...
2
votes
0answers
443 views

Overlay Union Geopandas improve performance

How to speed up the "union" of two shapefiles using geopandas? I have two large shapefiles: geodataframe_left.shape = (3610, 12) (500 MB) (link) geodataframe_right.shape = (16396, 3) (200 MB) (link)...
5
votes
1answer
5k views

Add CRS to a shapefile in Geopandas?

I am trying to add CRS to a shapefile that I am exporting: shp1= gpd.read_file(i[1],encoding='iso8859_7',crs_wkt='2100') shp1.to_file(out,encoding='iso8859_7',crs_wkt='2100') When I import it to a ...
4
votes
1answer
1k views

Buffer GeoPandas dataframe based on a column value

I have a GeoPandas dataframe with a series of polygons in the geometry column. I also have a bufferdist column for each row containing an integer. The dataframe looks like bufferdist geometry 0 ...
4
votes
1answer
6k views

Changing colours in GeoPandas?

I have a very simple map (http://www.nyc.gov/html/dcp/download/bytes/nybb_15b.zip) and I have never before worked with shapefiles in any way. Can someone tell me what I need to do in order to change ...
4
votes
2answers
4k views

Calculate distance between a coordinate and a county in GeoPandas

I have a single coordinate and a GeoPandas Dataframe representing US counties whose geometry is polygons that form the boundary of counties. Each of these polygons is also given through lat/lon pairs. ...
4
votes
2answers
5k views

Create a polygon grid using with Geopandas

I'm working with a geodataframe of points and I need to create a grid of rectangular polygons. I know how to have bounds of the geodataframe with gdf.geometry.bounds. Now using this information and ...
3
votes
1answer
479 views

Reading data to geopandas using WFS?

I'm new to GIS. Trying to use Finnish population data on 1km tiles available here: http://www.stat.fi/org/avoindata/paikkatietoaineistot_en.html The WFS service is here: http://geo.stat.fi/geoserver/...
3
votes
1answer
1k views

Find csv lat and long points in a shapefile polygon with geopandas spatial index

I have a csv with two sets of latitude and longitude points, and a shapefile with espg 4326. I want to find which points are inside the shapefile. I've been following the guide here which uses a ...
3
votes
1answer
371 views

Intersecting MultiLinestring based geodataframes with geopandas?

I would like to perform the following operation using geopandas. The segments are delimited by red points and the blue items are attribute information. My inputs are the first and second line ...
2
votes
1answer
1k views

How do I extract points from a LineString or Polygon data frame and make a dictionary of point data frames?

I am building some pre-processing routines for 3D visualization of GIS data and I have several line and polygon shapefiles with multiple features. I want to extract the points for each of the features ...
2
votes
2answers
1k views

Only read specific rows of a shapefile with GeoPandas / Fiona

I would like to read in only certain rows of a shapefile using GeoPandas. I've read approach for limiting columns of shapefile to read in, which I may use as well (Only read specific attribute columns ...
2
votes
1answer
2k views

Python Shapely - filling small gaps between multi polygons

I have a set of rectangular polygons, which currently form a directional path. The library I am using is Python Shapely / GeoPandas. The issue I am having is as the path changes direction, there are ...
1
vote
0answers
334 views

Add geopandas to cartopy

How can I add a geopandas geodataframe to a cartopy map? My objective is to create a large number of PNGs to turn into a GIF. The geopandas default plotting options are limited so I would like to ...
1
vote
0answers
46 views

shapely polygon leaves traces of other poly geometries after unary_union [duplicate]

I am trying to dissolve poly from a shapefile with unary_union and at times I am left with a poly that looks like this: You can see the lingering line geometries left inside of the poly. I have been ...
1
vote
2answers
770 views

Fiona throws KeyError when attempting to read a shapefile

I'm attempting to read the AADT_2014.shp file from the New York State Department of Transportation average traffic data (TDV_Shapefile_AADT_2014.zip specifically through fiona (by way of geopandas). ...
1
vote
1answer
2k views

Geopandas [Shapely] spatial difference: TopologyException: no outgoing dirEdge found

I am working on the "solver" that sequentially selects best location from the list, basing on poi and overlapping polygons within the certain buffer, then removes those points and location from the ...
1
vote
1answer
1k views

Inserting LiDAR points (from laspy) in GeoDataFrame without using a numpy array?

Working with Python 3.6 (Anaconda) under Windows using a laspy fork that works with Python 3 (https://github.com/sethrh/laspy). I am loading a LAS file to a GeoPandas GeoDataFrame to eventually ...
1
vote
0answers
217 views

Overlay two linestring objects in geopandas, accounting for the attributes

This is a follow up to Intersecting MultiLinestring based geodataframes with geopandas? in which I was trying to intersect polyline layers and carry the attributes over to a resulting overlay/...
0
votes
1answer
1k views

How to self union a GeoDataFrame?

I have a GeoPandas dataframe with lines all originating in the same location. I want to partition the lines into segments and merge them to get a dataframe containing all the unique segments. I tried ...