Questions tagged [geodataframe]

is a pandas.DataFrame that has a column with geometry

Filter by
Sorted by
Tagged with
1
vote
1answer
24 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 ...
2
votes
2answers
106 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 ...
0
votes
0answers
22 views

Iterating over two very large dataframes: finding the closest LineString (1/150k) to a Point (1/1.2m)

I have a dataset of calls (1.2m rows), each with a 'Point' geometry. Likewise I have a street dataset (150k rows), each with a LineString geometry. My goal is to identify, for each call, the closest ...
0
votes
1answer
37 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'...
1
vote
1answer
39 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&...
2
votes
0answers
100 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': ['...
3
votes
2answers
57 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 "...
3
votes
1answer
90 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 ...
4
votes
1answer
90 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
0answers
24 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
1answer
30 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 ...
1
vote
1answer
62 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
0answers
23 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
1answer
49 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
1answer
230 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
1answer
57 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
0answers
83 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='...
3
votes
1answer
191 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 ...
3
votes
1answer
160 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
1answer
95 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
1answer
60 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 ...
5
votes
1answer
812 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
1answer
64 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
1answer
28 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
1answer
360 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
2answers
59 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....
2
votes
1answer
1k 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
1answer
152 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 | ...
8
votes
2answers
3k 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
0answers
31 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 ...
4
votes
0answers
135 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 ...
2
votes
1answer
871 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
2answers
161 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 ...
0
votes
1answer
690 views

GeoPandas: Get the maximum length inside a polygon

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
1answer
2k 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
2answers
1k 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
1answer
587 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
0answers
294 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 ...
3
votes
1answer
608 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
1answer
212 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 ...
2
votes
1answer
8k 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': '...
2
votes
1answer
1k 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
1answer
30 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
0answers
333 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
1answer
48 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
0answers
452 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
2answers
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
1answer
1k 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
1answer
71 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
2answers
407 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'], ['...