Questions tagged [geopandas]
For questions about using GeoPandas in Python
1,525
questions
0
votes
2
answers
41
views
Efficiently removing smaller polygon of overlapping multipolygons [closed]
I have a geodataframe containing around 5000 shapely mutipolygons. Each of these multipolygons contains 2-10 polygons. Some polygons overlap with polygons of other multipolygons.
gdf = geopandas....
1
vote
1
answer
56
views
Create virtual/temporary layer from a GeoDataFrame in QGIS
I'm trying to make a plugin that lets me combine the Tracks from multiple GPX files into one virtual/temporary layer in QGIS.
Currently I have code that saves them as a GeoJSON layer but with a large ...
3
votes
1
answer
97
views
From Geodataframe to PostGIS
I have a geodataframe which I am trying to save to a postgis database.
I have already created a connection to postgis in pgAdmin (username, password, localhost and table)
from geoalchemy2 import ...
1
vote
1
answer
42
views
GeoPandas data types from PostGIS are always string
I am using GeoPandas from_postgis function to read data from PostGIS. However, the data types of the GeoPandas columns are always object.
Data I store in PostGIS is mixture of text/char, bool, integer ...
0
votes
0
answers
21
views
Generate and populate a grid from points in a geopandas dataframe [duplicate]
Context:
I have a geopandas dataframe, with two columns
'geometry': full of shapely.geometry.point.Point.
'h_mean': gathering the height of a surface at those points
I want to create a 2D spatial ...
0
votes
2
answers
57
views
Determining minx/miny/maxx/maxy for shape from polygon in GeoJSON file
I have implemented the following code to search a GeoJSON file for a point (not asking for a code review or critique):
#!/usr/local/bin/python3.11
import os
import sys
import fiona
import shapely
def ...
1
vote
1
answer
39
views
Finding intersection of two geospatial vector data in shapefile format using Python and GeoPandas
I have two geospatial shapefiles.
1. The first one is a contour shapefile, generated via following code
rasterDs = gdal.Open('raster.tif')
rasterBand = rasterDs.GetRasterBand(1)
contourPath="...
1
vote
1
answer
37
views
Warning message when doing spatial join nearest neighbor on GeoPandas
I am trying a nearest neighbor spatial join with two point Geodataframes but a warning message is appearing.
My code:
import geopandas as gpd
yield_2013=gpd.read_file('https://github.com/kevinkuranyi/...
0
votes
1
answer
22
views
Set Operation `intersection` and return only one gdf
I would like to find all polygons that intersect and return the original polygons; not the intersection. Lets go with the set operation example
from shapely.geometry import Polygon
polys1 = geopandas....
0
votes
0
answers
66
views
Dissolve lines that intersect after attending some dataframe (atributte table) conditions
I need to dissolve all Linestrings from a geodataframe that intersects each other after attending some tabular conditions: 1)have the same ID and 2) have the same opening year.
I am working with ...
2
votes
2
answers
31
views
Find the length of linestring shared between polygons
I would like to find the common area between my polygons, in this example my polygons touch and share a line
df = GeoDataFrame.from_file('path')
df
...
0
votes
1
answer
51
views
How to visualize a list of coordinates in [x.y] format?
I have a JSON file with coordinates representing roads stored in a list of lists. The coordinates are stored as [longitude, latitude] in a key called path. Example:
[[14.322689, 51.178513],
[14....
1
vote
2
answers
55
views
Interpolated Point on Line is not actually on Line?
I am trying to debug a problem and am not sure if it is my code or if there's a bug with shapely.
I have two geodataframes: one with points and one with lines. For each point in the points ...
-1
votes
1
answer
83
views
Splitting polygon between its neighbor polygons with Voronoi algorithm using Python [closed]
I would like to split the area of my concerned polygon (the blue one in the middle) between his neighbors polygons and affect each splitted area to a neighbor
My data looks like:
affectid
t
geometry
...
0
votes
0
answers
77
views
Trouble Reading GeoJSON Data in GeoPandas: "Failed to read GeoJSON data"
Trouble Reading GeoJSON Data in GeoPandas: "Failed to read GeoJSON data"
I am facing an issue while trying to read a GeoJSON file using the geopandas library. Whenever I attempt to load the ...
1
vote
1
answer
49
views
Reading single feature as dict into GeoDataFrame with GeoPandas
I have a Leaflet map where a user can select a feature and be able to download some data for that feature. I'm getting the object like this to pass to Python:
data = {
"type": "...
0
votes
2
answers
105
views
Deleting polygon constituted of many parts
I have a shapefile with multiple polygons and I would like to delete those which are constituted by multiple parts, as this one:
0
votes
1
answer
69
views
Read GeoJSON object in a CSV file column and transform it to geometry
I have a column ('geo_shape') that contains GeoJSON object type of linestring geometry and, so far, I didn't manage to read and transform it to a GeoPandas/shapefile type of geometry.
Here is a way ...
0
votes
1
answer
45
views
Get only polygons inside a bbox
I have a shapefile that has many polygons, here is an example:
Now, what I want to do is show the polygons that are around one particular location. So I don't have to show all the polygons.
So I ...
0
votes
1
answer
26
views
Detect if one point is inside polygons using GeoDataFrame
First I import a shapefile
import geopandas as gpd
shapefile_path = "data/TRI_75_SIG_DI/TRI_PARI_SIG_DI/n_tri_pari_carte_inond_s_075.shp"
gdf = gpd.read_file(shapefile_path)
And it works ...
-1
votes
1
answer
76
views
Matching correctly two same polygons that come from different shapefiles [closed]
I am trying to match two polygons that come from two different shapefiles, The one with the border (black line, MULTILINESTRING) and the one with blue color (multiple polygons) in the picture.
This ...
1
vote
0
answers
58
views
Change CRS of vector data on GeoPandas
I have a dataset for the Provinces in Canada obtained from statcan.ca. I am trying to visualize the data using GeoPandas library. I used the to_crs approach to reproject the dataset from its current ...
2
votes
1
answer
43
views
Intersection of two GeoDataFrames using Python [closed]
I have two GeoDataFrames:
The first one is a large grid (many small bounding boxes), each row is a bounding box saved as a polygon.
The second one contains just a few polygons (one polygon per row).
...
0
votes
1
answer
41
views
Generate lines from given azimuth and points in GeoPandas
I am reading a points shapefile containing the azimuth information in the attribute table, and I want to generate lines from these data. I have tried to use shapely.Point as a tool, however it can't ...
0
votes
0
answers
31
views
Using NetCDF data on Python
I've never worked with NetCDF data, but downloaded a file that is supposed to contain data "in a global grid at 5min spatial resolution".
I would like to know if my code is the right way to ...
1
vote
1
answer
56
views
Create Polygon out of minX, minY, maxX, maxY
I have a pandas dataframe with the min and max values from two polygons. How can I create two geometries (Polygons) out of these values using Geopandas or Shapely?
1
vote
1
answer
65
views
GeoPandas geofencing problem set up
I’m a Data Scientist but very new to geospatial analysis so I’m looking for some advice how approach a problem.
I’m trying to determine the speeds of cars that approach traffic lights within 200 ft. ...
2
votes
2
answers
325
views
Change GeoPandas geometry from GeometryCollection to MultiPolygon
I have a GeoPandas dataframe where the features have a Geometry type of 'GeometryCollection'.
It looks like each feature is in fact just a simple polygon, so I'd like to convert the GeometryCollection ...
0
votes
0
answers
75
views
GeoPandas: ShapelyDeprecationWarning: The 'type' attribute is deprecated, and will be removed in the future
I'm using python package geopandas to start an overlay analyze between two vectors, and I'm confused about the warning reports. Even though it doesn't report an error, there are two warnings, and I ...
1
vote
1
answer
59
views
Import shapefile into Networkx
I'm trying to import a shapefile into networkx, but I'm not achieving my desired topology.
Networkx's read_shp() function seems to be deprecated, so I decided to import the shapefile as a GeoPandas ...
0
votes
1
answer
87
views
TypeError("Must pass list-like as `names`."), Network generated via osm, geopandas, momepy. Objective: Run short path analysis via osmnx
I am trying to solve short path analysis via osmnx.distance.k_shortest_paths(G, orig, dest, k, weight='length')
I have used this approach as I am limited in the SSL/memory, that is why I am not using ...
0
votes
0
answers
22
views
How to fix error when plotting TypeError: 'MultiLineString' object is not iterable
I am following a Genetic Algorithm for optimizing a bus route network in github https://github.com/Schmidtbit/Bus-Route-Optimization. I have finished cleaning up most of the errors and getting the ...
2
votes
1
answer
277
views
GeoPandas: AttributeError: 'DataFrame' object has no attribute 'to_file'. Did you mean: 'to_pickle'?
I am at a complete loss, I have looked at other posts to no avail.
Following is the code I am trying to execute:
import os
import geopandas as gpd
root_dir = r"C:\Users\s.oneill\Desktop\SAMPLE\...
0
votes
1
answer
62
views
Exporting GeoDataFrame object with multi geometry columns to GeoJSON file
Is there a way to export GeoPandas GeoDataFrame with multiple geometry columns to a GeoJSON file? I tried the following but it gave an error:
import geopandas as gpd
from shapely.geometry import Point,...
0
votes
0
answers
52
views
Exporting polygons from GeoPandas to GeoJSON - end point is not the starting point
I'm quite new to working with GeoPandas, and I try to export the file to GeoJSON, to later display it on a map using Google Maps Platform.
While GeoPandas Polygons do not have to end in the same point ...
2
votes
1
answer
106
views
Fast quasi-recursive polygon intersection algorithm?
I'm trying to make a map which is colored based on the distance to a target point. I've done this by creating a series of concentric rings.
These rings are created by buffering out from the target ...
0
votes
1
answer
43
views
Make ordered numbers from intersections using GeoPandas
I'm have two shapefiles: points and line. What I want to do is to check
how many points are intersecting with/belonging to a single line feature, then I'd like to
order the points based on the line ...
0
votes
1
answer
208
views
Reading CSV with WKT column straight into a GeoPandas GeoDataFrame with geometries
Is there a good way to read CSVs that contain a WKT column straight into a GeoPandas GeoDataFrame?
I've seen several solutions that take a two-step approach:
Read the CSV into a Pandas DataFrame
Pass ...
-3
votes
1
answer
37
views
How this can work for multiple ring buffer [closed]
Let you tell me how to extend this capability to multiple ring buffer
2
votes
1
answer
67
views
Spatial join from points to polygons using GeoPandas gives me a points shapefile, not a polygons shapefile
I have the following points and polygons layers:
There is exactly one point attributed to each polygon, all accordingly within the corresponding polygon boundaries.
The points layer contains a binary ...
0
votes
0
answers
116
views
Geopandas+linux=pyproj.exceptions.ProjError: x, y, z, and time must be same size
I need to use the GeoDataFrame.to_crs("EPSG:4326",inplace=True) function to convert my vector layer to the WGS84 coordinate system.
My code was written on Windows, but the actual runtime ...
0
votes
1
answer
117
views
Downsample pointclouds from USGS (.LAZ) files in Python
I am trying to process pointclouds from USGS for a project and I am having a hard time working with the data (.LAZ files) because they are very large. They have around 36 million points. I tried ...
1
vote
0
answers
60
views
How to clip USGS LiDAR data and polygon files
Am kind of new to the whole Geo Info systems, I am trying to clip USGS lidar data which is (.laz) format using polygons in a (.shp) file. I am using Python 3.10: with packages laspy, geopandas. I use ...
1
vote
1
answer
26
views
Does geopandas handle shapefiles (in lat/lon) that straddle the anti-meridian properly?
I have been looking for a way to check if a point lies within a shapefile. i had some code that worked for the most part (using shapely and fiona) but my understanding is that it will exhibit ...
0
votes
1
answer
45
views
How to know the origins of the result of shapely's symmetric_difference?
Suppose I have two line geometries:
import shapely
line1 = shapely.geometry.LineString([(0, 0), (2, 0)])
line2 = shapely.geometry.LineString([(1, 0), (3, 0)])
shapely.symmetric_difference(line1, ...
1
vote
1
answer
56
views
Controlling the grid_size in geopandas' symmetric_difference method
Operations in Shapely
Suppose I have these two line geometries:
import shapely
link_12 = shapely.wkb.loads(b"\x01\x02\x00\x00\x00$\x00\x00\x00\xcc\xd4\x02\x96q\xb9-A\x8a+\xd1)\xda\x801A\xb1\xf3\...
0
votes
2
answers
396
views
Reading shape files : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 9: unexpected end of data
I am trying to read shapefiles. I have handled the error that could occur when reading a shapefile by writing a function read_gdf (see code below) but I am still getting an error UnicodeDecodeError: '...
2
votes
1
answer
223
views
Python length of roads inside polygons
I have two datasets: one about each road in a country (and its linestring), and another one about the polygons of each region. I want to estimate the length of each road in the polygon that is ...
1
vote
1
answer
62
views
How to use Geopandas to count intersecting features where there is a matching ID
Is it possible to use sjoin() or another method to get the counts of interesecting features between two geodataframes where the two geodataframes have a common id? For example, i would like to add a ...
2
votes
1
answer
44
views
Why the extents of GeoDataFrame and masked file are different?
vector = some shape file, MultiPolygon in GeoDataFrame. File crs and vector crs are the same.
vector.geometry
0 MULTIPOLYGON (((47.59780 -19.38530, 47.59330 -...
Name: geometry, dtype: geometry
...