Questions tagged [geodataframe]

is a pandas.DataFrame that has a column with geometry

Filter by
Sorted by
Tagged with
4
votes
1answer
52 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
68 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
33 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
26 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
35 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
58 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....
1
vote
1answer
286 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/...
1
vote
0answers
56 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 | ...
4
votes
2answers
1k 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
24 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
72 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
329 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
151 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
387 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 ...
1
vote
2answers
501 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
291 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
209 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 ...
1
vote
1answer
411 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
135 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
6k 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
613 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
26 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
274 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
382 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
2k 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
874 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
59 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
273 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
1answer
787 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
1answer
801 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
1answer
534 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
0answers
78 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
1answer
1k 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
1answer
395 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
0answers
42 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
2answers
5k 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
1answer
10k views

Getting AttributeError: 'DataFrame' object has no attribute 'to_file' from GeoPandas even though file converted into GeoDataframe instead of Dataframe

I have turned some R scripts for data cleaning/standardization of shapefiles into Python scripts. Here is the R code: x<-c(farm,field,"trialyield",2017) file<-paste(x, collapse="_&...
4
votes
2answers
5k views

Convert polygon bounding box to geodataframe?

I have a pandas dataframe that contains bounding box information for tiled raster data in the following format. left bottom right top 466583.40921 3135701....
3
votes
1answer
4k views

Geometry Data in GeoDataFrame will not plot

I want to import a CSV to use as a geodataframe. When I plot it, nothing shows, which makes me think I'm doing something wrong. Here's my code. import pandas as pd from geopandas import GeoDataFrame ...
0
votes
1answer
137 views

MapInfo Pro 64-bit - 16.0.3 - Snap Frame to Guideline (unable to?)

I am using MapInfo Pro 64-bit v16.0.3 In the layout, I want to snap my map frame to the guideline. I've noticed that when I create a rectangular box, this snaps to the guidelines once the edge is ...
0
votes
1answer
2k views

Why gdf.explode() doesn't work?

I'm trying to merge 2 geodataframes and combine all entities. So I use : cloudNshadow = gpd.overlay(cloud, shadow, how='union') cloudNshadow = cloudNshadow.unary_union() But it returns me : ...
1
vote
1answer
790 views

Intersection with Shapely and Fiona gives Key Error

I have written a script for standalone python based on this example for doing intersections of linestrings (representing streets) and polygons (representing gridcells) using shapely/fiona. The ...
21
votes
2answers
16k 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 ...
2
votes
1answer
6k views

CSV to Geodataframe : How to have valid geometry objects?

I'm writing a script with Geopandas. I try to use a csv of blocks to make a spatial join. So I convert it as a Geodataframe. But when I want to set geometry column it returns me Input geometry column ...
55
votes
2answers
67k views

Converting Pandas DataFrame to GeoDataFrame

This seems like a simple enough question, but I can't figure out how to convert a Pandas DataFrame to a GeoDataFrame for a spatial join? Here is an example of what my data looks like using df.head(): ...