Questions tagged [geopandas]

an open source project to make working with geospatial data in Python easier.

Filter by
Sorted by
Tagged with
3
votes
2answers
444 views

CRS from a planar projection around a point (pref. in Geopandas)

Is there a canonical way of projecting a set of points (for example, originally given in WGS84 latitudes/longitudes) into a planar approximation centered on a particular (latitude, longitude) pair and ...
6
votes
1answer
2k views

Trouble when Dissolving Geopandas Polygons

I have dissolved polygons with geopandas. However, the head of attribute table became values of this table. How can I fix this trouble? See:
3
votes
1answer
1k views

Geopandas performance appears quite slow

I'd like to confirm the performance I am observing when utilizing distance from a Geopandas Series. Problem Time to complete operations appears to be far greater than comparable operation in ...
1
vote
0answers
171 views

From the thousands of the overlaid polygons, get clusters of density

I have a few thousands of the polygons, over the given region. Many of them overlay. What I want is to detect areas, where density (number of overlaying polygons at the point) is substantially higher ...
3
votes
1answer
511 views

How to find coordinates from large CSV within multiple shapefile polygons

I have a CSV file of around 230 million rows, which contains a latitude column, a longitude column, a Date stamp, and an ID column. It look like this (I added the header in this example to help ...
3
votes
1answer
2k views

Converting a KMZ file containing an api link for use in python's geopandas

I've got a KMZ file which contains an API link for a map overlay, this is the link to that file. (The corresponding json file (link here), posted only gives me a link to a low resolution image and ...
14
votes
6answers
10k views

Reading raw data into geopandas

Is it possible to read raw data into a geopandas GeoDataFrame, a la a pandas DataFrame? For example, the following works: import pandas as pd import requests data = requests.get("https://data....
5
votes
0answers
419 views

What's the fastest way to convert large csvs to point shapefile

I'm working in QGIS, and my current method to change csvs to shapefiles is to import them to QGIS, right click and save as shapefile. For large CSVs (over 100 million rows) it can take quite some time ...
4
votes
1answer
6k views

Creating spatial join between points and polygons in GeoPandas?

I want to create a simple spatial join between points and polygons using GeoPandas but I think GeoPandas has bug? GeoPandas code: from geopandas import gpd import geopandas points = geopandas....
1
vote
2answers
2k views

Spatial join using python shapely and fiona

I want to create a python script when count how many points(from point shapefile) is in the polygons(polygon shapefile) and I want that count to create a new polygon shapefiles with the polygons where ...
1
vote
1answer
1k views

Create GPS (gpx) routes from GeoPandas geodataframe

I have a GeoPandas geodataframe with LineString geometries and I'd like to export them into .gpx files as GPS routes. I've searched for hints in the web but found anything useful. Are there ...
8
votes
1answer
9k views

Cannot get plot() in geopandas to produce a map of the GeoDataFrame

I have installed all the necessary and optional modules for geopandas (with the exception of rtree) as listed at http://geopandas.org/install.html I am following the tutorials from this site and also ...
27
votes
5answers
24k 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','...
11
votes
1answer
729 views

Python: Break linestring based on condition

I have a geopandas dataframe of a bunch of linestrings that have some data associated with each vertex/point: Point_x = (Lat, Lon, Time, ID, Data1, Data2, Data3) The points are converted to ...
2
votes
2answers
3k 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 ...
8
votes
1answer
14k 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 ...
17
votes
2answers
16k views

Getting polygon areas using geopandas?

Given a geopandas GeoDataFrame containing a series of polygons, I would like to get the area in km sq of each feature in my list. This is a pretty common problem, and the usual suggested solution in ...
1
vote
0answers
445 views

How to create a custom transverse mercator projection?

I'm working on a script that performs some simple geometric manipulations such as buffering vector data using shapely or geopandas. The input (i.e. original) shapefile could be geographically located ...
2
votes
1answer
3k 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 ...
5
votes
1answer
2k views

How to buffer a line with a flat cap style using geopandas?

I'm interested in buffering a linestring geometry using a flat cap style rather than the default round cap style using geopandas. I see shapely, which geopandas is based off, has the option to do that:...
3
votes
2answers
537 views

Preserve column order of GeoPandas file read

I have a shapefile I'm reading in using GeoPandas and then I do some geometry conversion of the data but in the process it unfortunately sorts the columns alphabetically. I need to preserve original ...
3
votes
1answer
1k views

Parsing WKB with python geos: ParseException: Unknown WKB type 16

I am pulling a WKB strings from the MYSQL table in pandas / geopandas, Python 2.7. As it is MySQL, the only way to read geometry is to parse it on the client. However, when parsing, geos raises an ...
0
votes
0answers
609 views

GeoPandas: interpolate for time X in timeseries

I've got some position data as a dataframe per target. Dataframe for target A: index TimeOfFix Lat Lon geometry 0 1478133083 -27.1124 34.3203 POINT(34.3203 -27.1124) 1 1478133085 ...
1
vote
2answers
1k 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). ...
2
votes
3answers
5k views

Choropleth map with GeoPandas and Folium error

I am trying to generate a leaflet Choropleth map as in https://pypi.python.org/pypi/folium. I am importing a shapefile as a geoDataframe which later on I am converting to a json file that I can ...
0
votes
1answer
274 views

Finding if point exists in shapefile using shapely performance?

I have a data frame that consists of 2 million rows (lat, lon) and I am trying to figure out if each of these points are in a boundary defined by a shapefile or not (intact I am looking at multiple ...
0
votes
1answer
3k views

Make a shapefile with geopandas from polygons

I am new in dealing with shapefiles. I have a dataset with points that represent centroids of polygons. I want to do a Voronoi tessellation and create a new shapefile with the obtained polygons ...
1
vote
0answers
334 views

GeoPandas cumulative value sum for intersecting polygons

I have a geojson file for all of the tax areas in the state of Utah. I read it into a GeoPandas dataframe. Now each row represents a tax area polygon. Many of the tax area polygons overlap each ...
4
votes
2answers
536 views

Weird output when projecting/interpolating points on lines

I am trying to project a points' shapefile on a multilinestrings' shapefile. (Project each point to the closest line) Here's my code : import geopandas as gpd import time start_time = time.time() ...
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
1answer
1k views

Calculating and setting length value for each row in a shapefile returns empty column

I have a Linestrings' shapefile to which I added a column named "length". I want to set the length of each row (geometry) in that column. Here's my code : import geopandas as gpd from shapely....
13
votes
1answer
9k 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 ...
1
vote
0answers
53 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 ...
3
votes
1answer
2k views

Return closest element in GeoSeries

Is there any built-in function or quick hack to efficiently return the closest element (index) to a point for a given geopandas GeoSeries? Something like >> geopandas.GeoSeries( >> { ...
14
votes
1answer
1k views

Why is Shapely's snapping (GEO snaps) not working as expected?

I'm trying to snap two lines to each other using Shapely/Geopandas but the result of the snapping is very odd. I tried : import geopandas as gpd from shapely.geometry import * from shapely.ops ...
5
votes
1answer
10k 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. ...
8
votes
2answers
5k views

Merging overlapping features using Geopandas?

I have a Shapefile with overlapping features. Is there an easy way to merge them with geopandas? I found a way with shapely, but I would like to do it with geopandas directly.
4
votes
1answer
1k views

Snapping two lines using Shapely

I'm trying to snap two Linestrings shapefiles using Shapely/Geopandas. I tried : import geopandas as gpd from shapely.geometry import * from shapely.ops import snap lines1 = gpd.GeoDataFrame....
2
votes
1answer
2k views

Selecting features from shapefile where field=“value” using Geopandas?

I don't understand the difference between OGR and Geopandas librairies. I have checked the documentation of GDAL as well as http://geopandas.org/ but I still don't get it. I just started learning ...
8
votes
1answer
13k 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 ...
3
votes
1answer
3k 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 ...
9
votes
2answers
13k views

Geopandas Polygon to matplotlib patches Polygon conversion

Unfortunately geopandas plotting is extremely slow and takes a lot of resources, hence I would like to use instead matplotlib for plotting. When I use pure Fiona to open and read the shapefile I ...
4
votes
1answer
667 views

Read only geometry from shapefile with python/geopandas

I would like to open a shapefile(shp) without loading the attributes(dbf), as I do not care about attributes and it takes about 25 minutes to load them. I am using Python Geopandas, so any Fiona or ...
7
votes
1answer
5k 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 ...
2
votes
1answer
112 views

Count Lat Lon Data Points Lying Between 2 Azimuths

I need to count the number of points (LAT, LON) from a cvs file that exist inside an arc defined by 2 azimuths. Ultimately it will need to be iterative where the arc defined by the 2 azimuths rotates ...
6
votes
1answer
1k views

GeoPandas GeoDataFrame plot statistics - how?

The plot method of a GeoPandas GeoDataFrame overrides the DataFrame parent method to plot the geometries of the associated GeoSeries. This is very convenient, but I'd also like to use the easy ways ...
4
votes
1answer
2k views

Finding problematic rows - spatial join in GeoPandas?

I have an sjoin function from geopandas that is behaving erratically: it works on some version of the "points" geodataframe but not others. merged=sjoin(points,polygons, how='left',op='within') The ...
5
votes
1answer
1k views

Geopandas and Zonal Statistic error

I'm trying to use Geopandas and zonal statistic from rasterstats together. I run this code import geopandas as gpd from rasterstats import zonal_stats geodf = gpd.read_file("SHP/shape.shp") ...
16
votes
3answers
8k 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 ...
5
votes
2answers
2k views

geopandas error “minimums more than maximums”

I posted this question on stackoverflow here, but it seems that gis.stackexchange is the more appropriate platform. I am trying to merge two geodataframes in geopandas (want to see which polygon each ...

1
9 10 11
12
13