Questions tagged [geodataframe]

is a pandas.DataFrame that has a column with geometry

Filter by
Sorted by
Tagged with
3 votes
1 answer
52 views

Concatenate two geodataframes: 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
  • 317
0 votes
0 answers
21 views

Convert from data to GeoDataFrame [duplicate]

I have this code and I need convert this information to GeoDataFrame. How can I do this? import requests url = 'https://gis.arlingtonva.us/arlgis/rest/services/public/Parking/MapServer/2/query' ...
Egor's user avatar
  • 9
1 vote
1 answer
45 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
  • 201
4 votes
1 answer
70 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
84 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
  • 317
1 vote
1 answer
255 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
  • 9,363
1 vote
1 answer
160 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
  • 9,363
1 vote
1 answer
314 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
  • 9,363
2 votes
1 answer
249 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
1 answer
241 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 - we're hiring's user avatar
0 votes
1 answer
117 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
  • 317
1 vote
1 answer
110 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
127 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
  • 649
5 votes
2 answers
891 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
  • 317
4 votes
1 answer
1k 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
  • 522
1 vote
1 answer
19 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
180 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
608 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
73 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
120 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
138 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
1 vote
0 answers
291 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,821
0 votes
0 answers
291 views

Clipping NetCDF files with a geodataframe in Python

I have monthly estimates of PM 2.5 for 20 consecutive years stored in NetCDF files with a precision of 0.01°x0.01° (i.e. for each 0.01°x0.01° square on the world map, there is an estimate of PM 2.5). [...
Galactus's user avatar
3 votes
1 answer
128 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
1k 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,201
6 votes
3 answers
2k 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
203 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
  • 393
4 votes
1 answer
164 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
863 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
376 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
5k 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
154 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
441 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
2 votes
2 answers
2k 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
521 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
  • 622
3 votes
1 answer
2k 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
  • 622
0 votes
1 answer
876 views

Convert JSON to GeoDataFrame and append both geometry and filename

I am currently running an experiment on automating a task by merging information from various file types and doing a number of operations to achieve this. Currently, I am reading a list of GeoJSONs ...
crisvr's user avatar
  • 65
4 votes
1 answer
2k views

Getting the percentage of how much areas intersects with another using GeoPandas

I have two GeoPandas dataframes, namely: grid - the base map that contains a grid of 100x100 meter squares. land - the land use of an area (e.g. farmland, meadow, etc.). How do I, upon spatially ...
SS-Salt's user avatar
  • 99
1 vote
1 answer
537 views

Can GeoPandas accept lists as property values?

Properties in GeoJSON features can be lists (or "arrays" in Javascript). For example, the following GeoJSON feature is formatted correctly, and includes a values property that is a list: { ...
Markus's user avatar
  • 113
0 votes
1 answer
308 views

Create a function that will return geodataframe

I have created the following function to take Origin = str, Destination = str, line = shapely.geometry.linestring.LineString, node = GeoDataFrame def create_lines_df(Origin, Destination, line_, nodes_)...
Kareem Alaraby's user avatar
2 votes
1 answer
2k views

Creating a geodataframe from a list of LineStrings or routes

I have created a separate LineString for each origin-destination couples of subdivisions and I did it manually cause when I use a for loop it creates a dataframe with 1 LineString from all lines... ...
Kareem Alaraby's user avatar
3 votes
1 answer
595 views

Displaying polygon on top of DEM with GeoPandas and Rasterio

I have a DEM and a polygon, both in the NAD83 Datum. I need to plot both at the same time. Plotting the polygon import os import rasterio import geopandas as gpd import contextily as cx import ...
BallpenMan's user avatar
  • 1,209
1 vote
0 answers
330 views

Buffer not working in GeoPandas [closed]

This seems pretty simple but I can't seem to create a buffer around a GeoDataFrame. I'm making this buffer so that it will be the extent of the axes instead of the original layer. This is to make the ...
BallpenMan's user avatar
  • 1,209
1 vote
1 answer
679 views

Get the sum of an attribute within a set radius for each row using GeoPandas

I have grid map that contains cells. Each cell is represented as a row in the dataframe, and each row contains the average population "pop" attribute. What I need is that for each of these ...
SS-Salt's user avatar
  • 99
3 votes
2 answers
3k views

Filtering GeoDataFrame rows with list of strings in GeoPandas

I want to filter GeoPandas GeoDataFrame rows by a list containing 4 'matches'; list_of_names = ['BE36_1000_1349', 'BE36_1000_1350', 'BE36_1000_1449', 'BE36_1000_1450']. I want to return four complete ...
Rose's user avatar
  • 315
0 votes
1 answer
2k views

Finding if point is in polygon then taking attribute from polygon dataframe and inserting it as a column in the point dataframe

I'm doing some GIS analysis in Python for COVID work. I've geocoded our entire membership (gdf_schoolAgedChildren) base and captured their locations in a shapely point data type (for each member). I'...
denpxc's user avatar
  • 11
1 vote
1 answer
228 views

Getting median value of attribute for duplicate polygons and dropping duplicates using GeoPandas

I have a DataFrame that resulted from spatially joining a digital elevation map with a square grid map. This unexpectedly resulted in duplicate rows where two rows will have the same "geometry&...
SS-Salt's user avatar
  • 99
3 votes
0 answers
3k views

AttributeError when setting coordinate system with set_crs() in GeoPandas [closed]

I'm trying to set the coordinate reference system for a GeoDataFrame using the following code: import geopandas from shapely.geometry import shape from shapely.geometry import Point d = {'col1': ['...
obeart's user avatar
  • 41
3 votes
2 answers
499 views

Getting polygon with max attribute within polygons with same geometry using GeoPandas

I have a GeoDataframe containing the spatially joined result of a square grid map and flood hazard data. However, there are instances of rows with the same "geometry" but differing "...
SS-Salt's user avatar
  • 99
3 votes
1 answer
4k views

Pandas DataFrame to GeoDataFrame with Polygon geometry using groupby and lambda

I have a pandas DataFrame like this name loc_x loc_y grp_name a1 1.0 2.0 set1 a2 2.0 3.0 set1 a3 3.2 4.1 set2 a4 7.9 4.2 ...
S_S's user avatar
  • 95