Questions tagged [geodataframe]
is a pandas.DataFrame that has a column with geometry
112
questions
5
votes
1
answer
1k
views
How does GeoPandas' representative_point() work?
I need to compute points that, unlike centroids, are assured to be within a geometry. GeoPandas offers the method geopandas.GeoDataFrame.representative_point(), but I cannot find how it works. ...
0
votes
0
answers
729
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
1
answer
160
views
Error when creating geodataframe from lists [geographic coordinates and GRIB CRS]
I'm working with meteorological data and I want to insert the grid points and also their polygon in a GeoDataFrame.
They are generated by ERA5 and in a GRIB format.
When I try to create the ...
4
votes
1
answer
8k
views
How to get lat and lon from a GeoPandas geodataframe polygon
I am looking to get the lat and lon coordinates for a number of different polygons in a geodataframe. The following code was suggested on another answer but this returns non lat and lon numbers (lon = ...
1
vote
0
answers
143
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
1
answer
1k
views
How to make necessary changes to Geodataframe to export as geopackage or shapefile
I am trying to export a geodatabase I created via the OMSNX package. ()
When I attempt to convert the file from a geodatabase to shapefile I get an error "ValueError: Invalid field type <class ...
2
votes
1
answer
3k
views
Plotting multiple maps using GeoPandas
I have two GeoDataFrames. The first one have the administrative boundaries of the 25 regions of a country. The second one, the urban fabric of the same country.
regions.head()
COD NAMEREG ...
0
votes
1
answer
335
views
Python convert GeoDataFrame to shapefile using ogr2ogr, unable to open error
I have a GeoDataFrame that I am trying to save as a shapefile using ogr2ogr. Based on the Q&A for Use GeoDataFrame as a osgeo.ogr DataSource and Using geopandas GeoDataFrame in gdal.Grid for ...
0
votes
0
answers
2k
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='...
4
votes
1
answer
942
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 ...
4
votes
1
answer
5k
views
Creating LINESTRING from two POINT(s) and finding mid-POINT
I would like to create a LINESTRING from two POINT geometries and then determine the mid-POINT. So, from my original Pandas' DataFrame, with "x" and "y" columns, I created the ...
0
votes
1
answer
1k
views
Attempting to get index value of Geopandas dataframes in list produces ValueError
When looping through a list of Geopandas geodataframes and attempting to get the index value of the current dataframe in the loop, I'm getting ValueError: Can only compare identically-labeled ...
4
votes
1
answer
92
views
Defining coordinate system for every GeoDataFrame (shapefile) in list
I am looking to set a coordinate system for every GeoDataFrame in a list of them. So I need this:
gdfs[0].crs = "EPSG:6668"
gdfs[1].crs = "EPSG:6668"
And so on but iteratively. I ...
13
votes
1
answer
9k
views
Shapely coordinate sequence to GeoDataFrame
Using the shapely bounding box function box, and a GeoDataFrameof points, I have extracted a bounding box and created a buffer around it (below gdf is a GeoDataFrameof points):
bbox=shapely.geometry....
3
votes
1
answer
326
views
Save geodataframes from list to separate shapefiles
I have a list of geodataframes which I imported from a folder full of shapefiles:
import glob
import geopandas as gpd
shapefiles = glob.iglob('E:/folder/shapefiles/*.shp')
gdfs = [gpd.read_file(file) ...
-2
votes
1
answer
333
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 | ...
0
votes
1
answer
2k
views
Error saving geodaframe to shp: AttributeError: 'Series' object has no attribute 'to_file'
I have been struggling with a problem related to Getting AttributeError: 'DataFrame' object has no attribute 'to_file' from GeoPandas even though file converted into GeoDataframe ...
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 ...
4
votes
2
answers
77
views
Build land classes from GIS data
I have combined geo-referenced terrain, climate, and soil data with the requirements of the different agricultural food crops in order to build land classes that tell you where which crop can be grown....
3
votes
1
answer
2k
views
geopandas GeoDataFrame.to_postgis is showing AttributeError: 'GeoDataFrame' object has no attribute 'to_postgis'
I have this geopandas geodataframe which I want to write in the postgis/postgreSQL database.
I have followed the steps as shown here by the geopandas docs
https://geopandas.readthedocs.io/en/latest/...
2
votes
1
answer
390
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 | ...
11
votes
2
answers
8k
views
Quick way to get WKT from a GeoDataFrame's geometries in GeoPandas?
Is there a quick way to produce a column/series containing the WKTs of all the geometries in a GeoPandas GeoDataFrame?
I got around this using the apply function (see example below), but I just ...
0
votes
0
answers
46
views
How to translate from GeoJSON to GeoDataFrame [duplicate]
I want to convert GeoJSON into a GeoDataFrame, but it doesn't work.
GeoJSON is stored in a dictionary variable.
If you know of a solution, I would like to know how to solve this problem.
This is my ...
5
votes
1
answer
489
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 ...
3
votes
1
answer
3k
views
Converting DataFrame with geometry column into GeoDataFrame in Pandas
I have this DataFrame:
In [120]: a
Out[120]:
a b c
0 111 333 [POINT (0 0)]
1 222 444 [POINT (0 0)]
I am trying to convert with the next line, but it fails:
In [125]: b = ...
4
votes
2
answers
185
views
Applying geometric operation on multiple GeoDataFrames
I have a collection of geodataframes in my Python environment. How can I apply for each GeoDataFrame the same spatial operation using following manner and create a new variable with the reference that ...
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 ...
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
2
answers
3k
views
Converting (Polyline Data) JSON to GeoDataFrame using GeoPandas
I have this particular json and I want to make the JSON into a GeoDataFrame (with geometry and its attributes); How to set the geometry and attributes to a geodataframe?
I have tried using geopandas....
1
vote
1
answer
2k
views
Attempting to get the distance between two Point objects. Getting AttributeError: 'GeoSeries' object has no attribute '_geom'
I am a beginner in GIS. Using the code below to get the distance between two Point objects from two separate GeoDataframe. Using the shapely distance function.
Can someone please explain to me what I ...
2
votes
0
answers
545
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 ...
5
votes
1
answer
1k
views
Getting geometry column integer SRID from a GeoPandas geodataframe?
The primary answer to Adding GeoPandas Dataframe to PostGIS table? requires entering the geodataframe geometry column's integer SRID.
Getting the CRS attribute using the crs attribute like so
import ...
1
vote
1
answer
385
views
Error while converting Dataframe to Geodataframe
I am trying to convert a table to a shapefile. To do that, I am storing that table in a dataframe and then I am trying to convert that dataframe to geodataframe using GeoPandas. But I am getting an ...
15
votes
1
answer
18k
views
Convert GeoJSON to GeoPandas GeoDataframe
I created the following GeoJSON object with this code:
from rasterio.features import shapes
polys = []
for shape, value in shapes(segments, transform=affine):
polys.append(shape)
[{'type': '...
4
votes
1
answer
2k
views
ValueError geopandas.sjoin: why does it not read my GeoDataFrame?
I'm working on a spatial join between a polygon from a shapefile and points from a CSV file, using geopandas.sjoin. I want to assign each point with a name of the province it is located in. I do know ...
1
vote
1
answer
51
views
GeoDataFrame - Unable to select range of linestrings
df = sample['geometry']
line_gdf = gpd.GeoDataFrame(geometry=[df[2], df[3], df[4], df[5], df[6], df[7], df[8], df[9]])
Above is the manual process of selecting Line Strings
In order to select from ...
1
vote
0
answers
471
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',
'...
2
votes
1
answer
51
views
Retaining last position of vessel position in geodataframe including time series?
I have geodataframe about vessel position which include unique code called 'mmsi' and time series. In the following 'mmsi' column has more than 1 'mmsi' code and time series (* mark).
mmsi ...
1
vote
0
answers
778
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
2
answers
3k
views
How to pull values from one geodataframe to populate corresponding column/rows in another geodataframe
I have 2 geodataframes; one made from polygons (bldg_res_df) and one from centroid points (parcel_res_df). I used .concat to combine them into a single geodataframe to do some calculations.
df_list = ...
2
votes
1
answer
2k
views
Why does spatial join on geodataframes return empty result?
I have two geodataframes that I want to perform a spatial join on; one is points, one is polygons. They are both dtype: int64. They both have .crs = {'init': 'epsg:4326'}. I have verified both of them ...
1
vote
1
answer
215
views
Why does geodataframe never complete?
I had a feature class made up of 1,700,000 polygons. I used Geopandas to create a geodataframe:
state = "MD"
state_gdb = r"C:\Projects\Pop_Alloc\{}_Data.gdb".format(state)
join_feat = "{}...
1
vote
2
answers
2k
views
How to create a sub dataframe from a dataframe using specific columns
I have a dataframe that has more fields/columns than I want, so I am trying to create a sub dataframe that only has certain fields/columns. The following throws a
TypeError: '(['uniqueid'], ['...
2
votes
1
answer
1k
views
How to merge geoseries to geodataframe based on geometry attribute
I have 5868 points in a geodataframe with some columns/attributes. Between points which have distance less than 10 m, I just want to select only one point as representation in that area. I have done ...
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 ...
0
votes
1
answer
882
views
Equivalent method for .withcolumn() for geodataframe
I am trying to use a user-defined function in pyspark in order to check whether the points in CANmep_GDF lie within the polygons in gda_GDF.
from geopandas import GeoDataFrame
def check_exist(geom):...
0
votes
0
answers
111
views
Locating observations that lies within a collection of Polygons (Python)
I'm trying to locate the observations that lie within a collection of Polygons but my current implementation takes forever, and I suspect that it is because the 'within' method needs to check all ...
2
votes
1
answer
2k
views
How to convert a spatial Oracle LOB object type to a Geodataframe listlike geometry object column
I have in my dataframe one column with cx_Oracle.LOB object [2D polygon type], made with a SDO_UTIL.TO_WKTGEOMETRY SQL function and I want to create a geodataframe, and set my geometry column the ...
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 ...
1
vote
0
answers
53
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?