Questions tagged [geodataframe]

is a pandas.DataFrame that has a column with geometry

Filter by
Sorted by
Tagged with
0 votes
0 answers
41 views

Reading shapefiles: Can only read the geometry

I have a function which reads various shapefiles as follows: def read_gdf(file:str,crs:str,current_crs:str)->gpd.GeoDataFrame: collection = list(fiona.open(file,'r', encoding='iso-8859-1')...
bravopapa's user avatar
  • 475
0 votes
0 answers
33 views

Intersection of polygons [duplicate]

I have a brown polygon which intersects two purple polygons: I d like to make sure that the brown polygon (64981Cas) is allocated to the purple polygon with the highest intersection area (the polygon ...
bravopapa's user avatar
  • 475
0 votes
0 answers
36 views

Getting an empty Python geodataframe while I perform spatial join operation on - polyline/line and points

import os os.environ['USE_PYGEOS'] = '0' import geopandas as gpd sv=gpd.read_file(r"D:\Sampledata\Kerala\Schools.shp") sr=gpd.read_file(r"D:\Map\Kerala\Road_line.shp") gh=gpd.sjoin(...
Badboy's user avatar
  • 29
0 votes
1 answer
54 views

Why the buffer geometry column in the GeoDataFrame is in point form although it's actually in polygon form?

I wanted to create a 1.5km buffer for each geocoded point. Here's the screenshot of the geocoded points dataframe. So I overwrote the geometry column using the code below: shopping_centres['geom'] = ...
mfirdaus_96's user avatar
0 votes
1 answer
58 views

How do I create a Geodataframe which the data is grouped by User ID & the timestamp is sorted from oldest to most recent?

I've been struggling to complete this exercise (Exercise 2 Problem 3) which you guys can refer to this link. A reminder that the kruger_points.shp is obtained from Exercise 2 Problem 2. Here's the ...
mfirdaus_96's user avatar
1 vote
1 answer
77 views

Intersection between polygons. Is gpd.sjoin adjustable?

I am looking to intersect two polygons. See picture below: The intersection is between the pink polygon (the small one) and the purple polygon (the bigger one). My issue is when I do the intersection ...
bravopapa's user avatar
  • 475
3 votes
1 answer
56 views

Incompatible numeric format between points and polygons geometry in GeoPandas

I am reproducing an exercise on GeoPandas. Basically, I want to check whether points are within a given polygon. However, polygon format numbers are quite different. They seem huge (possibly because ...
Saulo Carvalho's user avatar
2 votes
0 answers
53 views

Handling Nulls with QgsVectorLayer.getFeatures() and GeoDataFrame.from_features()

I am trying to convert selected features in a QgsVectorLayer to a GeoDataFrame. The input layer contains values including nulls across multiple floating, integer or string columns. For Example: When ...
cratcliff's user avatar
  • 156
2 votes
2 answers
180 views

Removing polygons from GeoDataFrame which do not intersect with any polygons of other GeoDataFrame using Python

I am looking for an efficient way to remove any polygons from a GeoDataFrame which do not intersect with any polygons of another GeoDataFrame. I tried it the following way which seems really ...
wup017's user avatar
  • 23
2 votes
1 answer
146 views

Converting input polygon to GeoDataFrame in Python

I am in the process of developing a plugin for QGIS and I need to convert an input vector layer (containing a polygon) into GeoDataFrame. The input layer is imported like this: input_Area = self.dlg....
H. Lange's user avatar
0 votes
0 answers
172 views

Creating a GeoPandas dataframe from GeoDjango query, then extracting latitude values for Plotly

I am attempting to use information from my PostGis database with my Django application to make a 3d scatter in Plotly. I have timeseries data in my database with different metrics from vehicles, and ...
CatByte-io's user avatar
0 votes
0 answers
78 views

Plotting geodataframe with holoviews

I have a geopandas data frame combined_gdf that consists of circular polygons like below. fid Plot_name Registered Longitude Latitude geometry 0 130.0 2014-10-29 1 -51.460000 -1.740000 ...
Sher's user avatar
  • 894
1 vote
1 answer
502 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": "...
MKF's user avatar
  • 571
0 votes
2 answers
96 views

Looping through folders to read shapefiles [closed]

I would like to adapt a function, that reads many shapefiles in one specific folder, to read many shapefiles in many folders. Here is the function that reads multiple shapefiles in ONE folder. def ...
bravopapa's user avatar
  • 475
2 votes
1 answer
67 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 ...
Max Poltora's user avatar
0 votes
0 answers
47 views

Spatial join of multiple GDFs and extract values

I have several different polygon geodataframes: I would like to get the interseting area of one to another. I was able to do it like that: frames = [oranzove, modre, cervene, tyrkysove] empty = [] ...
adamekcerv's user avatar
3 votes
1 answer
676 views

Concatenating two geodataframes needs CRS Adjustment

I have two geodataframes which I would like to concatenate. I have tried this: test=gpd.GeoDataFrame( pd.concat( [gdf1, gdf2], ignore_index=True) ) where print(gdf1.columns) and print(gdf2.columns) ...
bravopapa's user avatar
  • 475
1 vote
1 answer
329 views

Selecting and removing polygons that overlap within a single GeoDataFrame in Python

I have a GeoDataFrame made of polygons- some overlapping, some not (see picture above). I'd like to create a shapefile or GeoPackage of only the polygon centroids that are not overlapping. There is a ...
user2031's user avatar
  • 221
4 votes
1 answer
150 views

Computing parallel polygons based on given perpendicular distance in GeoPandas

Say I have a GeoPandas GeoDataFrame of polygons (i.e. the "geometry" column contains polygons of GPS coordinates only). import geopandas as gpd from shapely.geometry import Polygon ...
Tristan Tran's user avatar
1 vote
0 answers
220 views

geopandas.sjoin : Does the size of the polygon matters?

I am doing a spatial join with geopandas as follows: joinIlots = gpd.sjoin(left_df=Area, right_df=data, how="left", predicate="intersects") The geodataframe data represents ...
bravopapa's user avatar
  • 475
1 vote
2 answers
1k views

Get the name of the geometry column(s) of a GeoDataFrame

Sometime, the name of the geometry column of a GeoDataFrame is simply not 'geometry' but a custom name which in some situations cannot be known in advance because it may have been defined dynamically ...
swiss_knight's user avatar
  • 10.3k
1 vote
1 answer
582 views

(Geo)DataFrame left join leads to NaN in all right values

Let these two CSV files on the disk: $ cat /path/to/gdf0.csv myid,geometry 332,"MULTIPOLYGON Z (((0 0 0, 0 0 1, 0 1 1, 0 0 0)))" 220,"MULTIPOLYGON Z (((1 1 1, 1 1 2, 1 2 2, 1 1 1)))&...
swiss_knight's user avatar
  • 10.3k
1 vote
1 answer
869 views

Loading back a dumped GeoDataFrame leads to: `GeoDataFrame does not support multiple columns using the geometry column name 'geometry'.`

Let the following file be the result of a GeoDataFrame dump to a CSV file: gdf.to_csv('/path/to/gdf.csv') $ cat '/path/to/gdf.csv' myid,geometry 332,"MULTIPOLYGON Z (((0 0 0, 0 0 1, 0 1 1, 0 0 0)...
swiss_knight's user avatar
  • 10.3k
2 votes
1 answer
991 views

GeoPandas .set_geometry() does not update Geometry of GeoDataFrame

I'm trying to implement a transformation of x and y coordinates for line features of a Shapefile. geopandas.set_geometry() isn't setting the x and y coordinates and isn't giving me any errors. Here is ...
zwnk's user avatar
  • 390
3 votes
2 answers
1k views

Creating GeoJSON from GeoDataFrame with feature IDs but without bbox using GeoPandas

Here is the creation of an example GeoDataFrame, gdf: import shapely.wkt import geopandas as gpd s0 = shapely.wkt.loads("POINT(0 0)") s1 = shapely.wkt.loads("POINT(1 1)") gdf = ...
zabop's user avatar
  • 2,204
0 votes
1 answer
292 views

Reading multiple shapefiles and getting error 'A LinearRing must have at least 3 coordinate tuples'

I am reading multiple shapefiles (around 14) using the function below: def import_shapes_list(path_to_data:str,shapes_folder:str,crs:str) ->gpd.GeoDataFrame: """ ""&...
bravopapa's user avatar
  • 475
2 votes
2 answers
365 views

How to read geoDataFrame into GDAL function?

I would like to use gdal function in python to convert vector file with polygons to raster (example below). As an input vector data I need to use geoDataFrame (geopandas). Is there a way to read ...
Grzegorz's user avatar
2 votes
1 answer
321 views

Applying cross join or cartesian product (database table join) for GeoDataFrames using GeoPandas [closed]

I have a set of points and I want to calculate the distance from each point to all other points in GeoDataFrame. This is my GeoDataFrame: id Longitude Latitude geometry 0 1 -71.275580 ...
milad's user avatar
  • 719
5 votes
2 answers
4k views

Intersection of two GeoPandas Dataframes

I have two GeoPandas dataframes titre_polyG and df which I have intersected as follows: titre_polyG is as follows: 0 MULTIPOLYGON (((-7.64026 33.59134, -7.63996 33... 1 MULTIPOLYGON (((-7....
bravopapa's user avatar
  • 475
4 votes
1 answer
3k views

Using sjoin in GeoPandas

I have a GeoDataFrame with 12.431 observations of geographical units, called "cities". I also have another layer file with points, called "points". Both of them are in CRS: ...
OgeiD's user avatar
  • 546
1 vote
1 answer
46 views

ValueError when selecting raster files that overlap an AOI using GeoPandas

I want to select only the raster files that overlap or intersect my AOI. I have a list of 900 raster files, and I calculate their footprints. Besides, I have my AOI. Both, the footprints and the AOI ...
Alexandra Villacis's user avatar
1 vote
1 answer
319 views

Loop through geodataframe, append 0 values between 2001-2021

I have produced a GeoPandas geodataframe (attached) with rows containing "loss_year" between 2001 and 2021, and some area values (pictured). I wish to append the omitted years between 2001 -...
Stuey17's user avatar
  • 199
1 vote
1 answer
1k views

Intersect/overlay multiple geodataframes from list using python (geopandas)

I am trying to overlay multiple gdf from list at once. I have tried this code: GDF_list = [gdf_1, gdf_2, gdf_3, gdf_4] for DVP in GDF_list: DVP = gpd.overlay(gdf, GDF_list, how='intersection') ...
adamekcerv's user avatar
0 votes
1 answer
107 views

Add raster pixel information to existing geodataframe, one column per band

I have a land cover dataset (a geopandas.GeoDataFrame) with a series of "buffers" over a territory. The dataset has roughly this format: unit_id , ..., geometry, 30 ...
tutuca's user avatar
  • 101
0 votes
1 answer
296 views

Geodataframe to SHP in loop and name of the GDF

I am trying to export multiple gdf to shp and name these shp by the gdf name. I have found this solution here is my list: maloobchod_list = [maloobchod2006_geom, maloobchod2011_geom, ...
adamekcerv's user avatar
0 votes
2 answers
190 views

Clip data using GeoPandas or PostGIS [closed]

I have two geodataframes - points. First gdf contains smaller number of points. I am trying to clip my second gdf (with higher number of points and therefore bigger area) to the extent of first gdf. ...
adamekcerv's user avatar
2 votes
0 answers
492 views

Why will Geopandas not read geopackage into dataframe? [closed]

I am trying to read in a geopackage as a dataframe using Geopandas. I am using Python 3.8, Geopandas 0.10.2, and Fiona 1.8.20. The geopackage I was using to test this is publicly available in any of ...
gwydion93's user avatar
  • 1,903
3 votes
1 answer
221 views

Preserving None values in GeoPandas when dissolving (by="id", aggfunc="first", as_index=False)

If I dissolve two geometries with the same id and tell to aggregate the other attributes from the first geometry, I get the attributes values from the second geometry because the first is None. ...
Patrick Baumann's user avatar
2 votes
2 answers
2k views

Writing empty GeoDataFrame to shapefile using Python

I don't know why this is so hard to find or to do, but how does one create an empty .shp with geopandas? I essentially want to duplicate the processes of creating a type: polygon shapefile from QGIS, ...
Binx's user avatar
  • 1,350
6 votes
3 answers
4k views

Extracting latitude and longitude pairs as list from LineString in GeoPandas

I have a GeoPandas GeoDataFrame that looks like this: shape_id geometry 1000252 LINESTRING (4.91790 52.34725, 4.91797 52.34715... 1000254 LINESTRING (4.80382 52.34495, 4.80413 52.34500... ...
sampeterson's user avatar
2 votes
1 answer
378 views

Converting QGIS feature selection into dataframe to allow plotting

I have a layer containing thousands of points of X,Y,Z data (sample below). fid field_1 field_2 field_3 1 525146 675224 -342.1 2 525148 675224 -342.2 3 525150 675224 -342.1 4 525152 ...
WillH's user avatar
  • 455
4 votes
1 answer
272 views

Unable to execute spatial join after CRS transformation in GeoPandas

I'm trying to join a points GeoPandas GeoDataFrame with a polygon GeoDataFrame, but I'm getting an empty results (inner join). The points GeoDataFrame I'm loading it by using latitude and longitude. ...
Miguel Ángel Lobato's user avatar
4 votes
2 answers
2k views

Reading Inspire XML with GeoPandas

I am trying to plot the German Railway net from here, using GeoPandas. It downloads an Inspire XML file. gpd.read_file only seems to read the header. Importing it as a Pandas Dataframe with pd....
Maartenk's user avatar
1 vote
1 answer
677 views

Encoding issue while making GeoDataFrame from shapefile using URL

The dataset I want to use have some special characters like ü, õ, ö, ä. which cause encoding issue. The below example runs totally fine and doesnt mess up those characters. gdf_local = gpd.read_file(r'...
SpatialAnalyst's user avatar
4 votes
2 answers
11k views

Using Shapely methods (explain_validity and make_valid) on shapefile

I'm trying to find and repair invalidity in my polygons. I have already found out that 10 polygons have self-intersection problems in QGIS, trying the same thing with shapely. This is my code: import ...
Ki-code's user avatar
  • 63
0 votes
0 answers
257 views

Applying functools.reduce to make Geopandas geometries valid for unary_union

I want to calculate the total area of a GeoDataFrame, year_df, where the geometries overlap so I need to take the union. I was running into an issue with unary_union (some TopologyException that the ...
user1880610's user avatar
0 votes
0 answers
694 views

A faster way to extract geometry xy of geodataframe

I need a faster way to extract geometry xy of a large dataset which is in a geodataframe format. I have developed a lambda function as below to do that but I need a faster way. The following is a ...
rgholizadehr's user avatar
4 votes
2 answers
4k views

Check if geometry field in GeoPandas geodataframe have any row with specific type

This question is related to: Filtering by geometry type in GeoPandas I need to check if my geodataframe contains 'MultiPolygon' type. Below is my attempt, but it doesn't work. According to ...
Karol Zlot's user avatar
2 votes
1 answer
706 views

Fill NaN geometries records with other geometric column

I have a GeoDataFrame with two geometry columns. I want to fill missing values of the one with the other. Both columns contain polygons or multipolygons. I have tried: geo_df['geom_2'].fillna(geo_df['...
Ofir's user avatar
  • 677
3 votes
1 answer
4k views

Using multiple predicate parameters on sjoin in GeoPandas

Looking for a way to run GeoDataFrame.sjoin() with more than one predicate. For example, on QGIS' "Join by location" tool, there is a check box of predicates to mark as needed. When trying ...
Ofir's user avatar
  • 677