Questions tagged [geodataframe]
is a pandas.DataFrame that has a column with geometry
25
questions with no upvoted or accepted answers
3
votes
2
answers
1k
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 ...
3
votes
1
answer
692
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
0
answers
58
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 ...
2
votes
2
answers
467
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 ...
2
votes
0
answers
254
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 ...
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 ...
2
votes
0
answers
614
views
Write GeoPandas df to PostGIS - Linestring Z geometry
I am trying to write a geodataframe with Linestring Z geometry to a PostGIS table.
This rise the error:
ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'LineString'
[SQL: INSERT INTO ...
2
votes
0
answers
1k
views
Create a GeoDataFrame with more than one geo_column
I am working with PostgreSQL/PostGIS and geopandas. I have tables with more than one geometry.
How can I move this kind of tables to geopandas recognizing all the geometries columns? I am using ...
1
vote
0
answers
38
views
to_crs method does not seem to change the projection correctly in GeoPandas
I am trying to project a .shp file from ESRI:102020 to ESRI:4326 (WGS 84).
This is my code:
import geopandas as gpd
mpa = gpd.read_file(fn)
mpa1 = mpa.to_crs("epsg:4326")
When plotting the ...
1
vote
0
answers
240
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
1k
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
520
views
Cannot create geodataframe from feature class due to IndexError: list index out of range
I have a function that helps me read in large feature classes and them create a geodataframe:
line_feat = "S_Studies_Ln"
cnms_cols = ['REACH_ID', 'STUDY_ID', 'CO_FIPS', 'CID', 'FLD_ZONE',
'...
1
vote
1
answer
679
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 ...
1
vote
0
answers
61
views
Python function like SAGA Grid Gridding?
For a python script, I'm searching for a function that does the same as SAGA Grid gridding, an exponential interpolation on GeoPandas GeoDataFrame.
Does anyone know one?
0
votes
0
answers
25
views
make_geocube : cannot convert float infinity to integer (when I change CRS it works)
I have this geodataframe, incremenents_raster, that I wanted to rasterize :
-----------------------------------------------------------------------------
frame_id 2017-01-01 2017-01-16 2017-02-01 2017-...
0
votes
0
answers
50
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')...
0
votes
0
answers
38
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(...
0
votes
1
answer
70
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 ...
0
votes
0
answers
101
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 ...
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 = []
...
0
votes
0
answers
271
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 ...
0
votes
1
answer
778
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 ...
0
votes
0
answers
1k
views
Adding a new point to a graph in NetworkX
I am working with some points between which I need to find the shortest paths along a graph in NetworkX. I'm trying to take a point that is currently not on the graph and connect it to the graph, i.e.,...
0
votes
0
answers
3k
views
ValueError: 'ITEM' is both an index level and a column label, which is ambiguous
I'm trying to process some data, with geopandas0.9.
Here is my code:
locations = select_polygons.groupby(class_col).apply(lambda x: \
sample_locations_from_polygon(x, sample_on_boundary='...
-2
votes
1
answer
839
views
How to change column value by matching row value in data frame?
Say I do have the following table
| longitude | latitude | temperature | label |
|-----------|----------|-------------|-------|
| x | y | z | 1 |
| p | q | ...