Questions tagged [geodataframe]
is a pandas.DataFrame that has a column with geometry
113
questions
0
votes
0
answers
21
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 = []
...
5
votes
1
answer
495
views
Finding union of many geodataframes using GeoPandas
I have a series of many GeoPandas Polygon objects, each with an associated exposure time. My goal is to find the union of all the Polygons in order to create an exposure time map.
For each Polygon in ...
4
votes
3
answers
12k
views
How to convert GeoSeries polygons to lists of coordinates?
I have a GeoDataFrame consisting polygons. How can I convert each polygon into a list of coordinates? Is there any attribute, method or function in GeoPandas to do this?
3
votes
1
answer
57
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) ...
4
votes
1
answer
949
views
Exporting multiple GeoPandas GeoDataFrames to one KMZ file
I have two GeoPandas GeoDataFrames, and I want to export them to a KMZ file with a nested folder structure. Below is a stand-alone code to create the GeoDataFrames, and a screenshot of how I would ...
2
votes
1
answer
391
views
geopandas to_postgis: ValueError: geom (geometry(MULTILINESTRING,4326)) not a string
I have a GeoPandas GeoDataFrame with a column named geom having MultiLineString values as such:
print(gdf.to_markdown()) # using package 'tabulate' to display a markdown table
| | uid | key | ...
2
votes
1
answer
3k
views
AttributeError when converting DataFrame to GeoDataFrame with Polygon
I imported a shapefile in the form of a pandas.DataFrame and ran operations on it. But I can't convert the DataFrame to a GeoDataFrame. I tried with gpd.GeoDataFrame, and with wkt.loads. I think it's ...
1
vote
1
answer
47
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 ...
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'
...
1
vote
1
answer
595
views
How to create a shapefile [polygon type] from a Geodataframe, returned from a Oracle Spatial cursor with geometry column type=cx_Oracle.LOB?
I'm trying to create a shapefile [2D polygon type] with a Geodataframe, that result from a SQL made to a Oracle Spatial database.
The SQL and the Geodataframe creation runs without errors, but when I ...
4
votes
1
answer
78
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
...
3
votes
1
answer
596
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 ...
1
vote
1
answer
325
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)...
1
vote
0
answers
87
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 ...
1
vote
1
answer
171
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)))&...
1
vote
1
answer
269
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 ...
2
votes
1
answer
263
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 ...
3
votes
1
answer
257
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 = ...
1
vote
1
answer
113
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 ...
0
votes
1
answer
120
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:
"""
""&...
2
votes
1
answer
133
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 ...
1
vote
0
answers
144
views
Rasterize multiple polygons and calculate average
I have a vector layer that contains many overlapping polygons, each containing a "Value" in the attribute table. I am trying to rasterize each polygon as an individual raster layer, and then ...
1
vote
0
answers
333
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 ...
5
votes
2
answers
940
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....
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 ...
14
votes
1
answer
45k
views
AttributeError "'int' object has no attribute 'encode'" when writing GeoDataFrame into shapefile or spatialite with GeoPandas
I am trying to save a GeoDataFrame as a shapefile or spatialite, but for some reason, I get this error:
File "fiona\ogrext.pyx", line 951, in fiona.ogrext.WritingSession.start (fiona/ogrext....
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: ...
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 ...
4
votes
2
answers
6k
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 ...
1
vote
1
answer
186
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 -...
1
vote
1
answer
626
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')
...
0
votes
1
answer
74
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 ...
0
votes
2
answers
141
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. ...
0
votes
1
answer
123
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, ...
1
vote
0
answers
296
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 ...
0
votes
0
answers
298
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). [...
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, ...
7
votes
2
answers
24k
views
Extracting points from LineString or Polygon and making dictionary out of them in GeoPandas
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 ...
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...
...
3
votes
1
answer
129
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.
...
4
votes
1
answer
168
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. ...
2
votes
1
answer
207
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 ...
4
votes
2
answers
878
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....
1
vote
1
answer
383
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'...
2
votes
1
answer
1k
views
Getting maximum length inside polygon using GeoPandas [closed]
I'm having a a GeoDataFrame of polygons. I want to find the maximum length of a straight line that can fit inside each polygon. You could call this the characteristic length of the polygon. The length ...
0
votes
0
answers
155
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 ...
34
votes
3
answers
29k
views
Creating polygon grid using 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 ...
0
votes
0
answers
446
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 ...
4
votes
1
answer
5k
views
Converting DataFrame to GeoDataFrame with Polygon [closed]
I would like to convert my DataFrame to GeoDataFrame, but every post is about points. I need to convert polygons. Coordinates are in df['geometry']. How can I do that?
My DataFrame is below:
I was ...
2
votes
1
answer
2k
views
Geopandas intersects/contains fails between GeoDataFrames
I am struggling to make the GeoDataFrame functions: intersects/contains work between GeoDataFrames instances.
Let t be a GeoDataFrame with contents:
id ...