Questions tagged [geopandas]

an open source project to make working with geospatial data in Python easier.

239 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
688 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 ...
2
votes
0answers
480 views

Intersecting shapefile/GeoDataFrame using Geopandas, shapely etc?

I'm currently transferring from ESRI to open source GIS by recreating basic ArcGIS tasks in Python, mainly using Geopandas since I have some experience with Pandas. Now I'm trying to intersect a ...
2
votes
0answers
1k views

Error in reproject vector file using GeoPandas

I have a vector file (in this case shp file) and I read it with GeoPandas (gpd). vector_folder = r'C:\poly' vector_file = 'poly.shp' df = gpd.read_file(os.path.join(vector_folder,vector_file)) df ...
2
votes
0answers
706 views

How to get fast writing with Geopandas & Fiona?

I have a GeoDataFrame with 1,2M records, and want to write it into a GeoPackage file. Currently, it takes >20 minutes, and, as I calculated, average write speed is 100 recs/sec. As I read in the ...
2
votes
0answers
5k views

display geojson file with folium (using geopandas to generate file)

I can not display properly a geojson file in folium using the GeoJson function. My file is made with geopandas, has some tags as fields and also a geometry field. In each row, in the field of geometry,...
2
votes
0answers
380 views

geopandas' .crs doesn't store crs on 'proj' file

As occurred in this question: Add CRS to a shapefile in Geopandas? f.shp has not crs This code: shp=gpd.read_file('f.shp') shp.crs = {'init' :'epsg:2100'} out=path shp.to_file(out) doesn't ...
2
votes
0answers
557 views

ValueError: Geometry column cannot contain mutiple geometry types when writing to file

I have this list: shapefiles that has these directories for the files: (pairs of pst and dbound) in each folder. [['C:\\Users\\user\\Desktop\\eff\\20194\\DBOUND\\DBOUND.shp', 'C:\\Users\\user\\...
2
votes
0answers
864 views

Get raster pixel value within a shapefile polygon

I have the below GeoPandas dataframe that has: two columns: geometry and raster_val 13 rows The first row is shown below. geometry raster_val 0 ...
2
votes
0answers
359 views

geopandas dissolve versus postGIS postgresql aggregated groupby dissolve

I have a geodataframe for which I want to dissolve the geometry based on an attribute (fao_id). In geopandas this is easy as gdf.dissolve(by="fao_id", aggfunc="first") but unfortunately this fails due ...
2
votes
0answers
3k views

GeoPandas save to shapefile issue: Unable to open EPSG support file

When I try to use to_file() to write a GeoPandas GeoDataFrame to a shapefile I get the following error. df3.to_file('~/Desktop/testout.shp', driver = 'ESRI Shapefile'); ERROR:Fiona:OGR Error 4: ...
2
votes
1answer
25 views

Matching points to polygons and handling points NOT in polygons

I have two GeoDataFrames: one with 191k address points and another with 18 polygons representing catchment areas for specific schools. Theoretically, every address should fall into one of the zones. ...
1
vote
0answers
21 views

Adding custom names to a GeoPandas legend

I have a shapefile which has an attribute table with a column I would like to make a map/plot of. The attribute values are numerical (integer). I have made two dicts to map the colors and names I want ...
1
vote
0answers
16 views

Spatial join two identical layers

I'm working with Python and GeoPandas. I have two parcel layers that are identical and in the same coordinate reference system. The parcel number field is not unique so I am unable to join on that ...
1
vote
0answers
18 views

Opening gkpg in geopandas throws: UnsupportedGeometryTypeError: 12

I wanted to open a gkpg file in geopandas 0.8.2, on windows, using conda mith channel conda-forge obj = r'path.gpkg' layer="layername" gdf = gpd.read_file(obj, layer=layer) Throws the ...
1
vote
0answers
50 views

Detect one-way road from origin_id and destination_id

How do I detect the one-way roads? I have a graph G( MultiDiGraph(G) with origin(Id) and destination(Id) nodes. I would like to detect one-way roads. Example if there is an edge from the origin "...
1
vote
0answers
44 views

Count overlapping features using Geopandas

Is there a way to easily count overlapping polygons using Geopandas, the same way as the ArcGIS Pro Count Overlapping Features works? So far my approach was to do union overlay and then dissolve with ...
1
vote
1answer
18 views

Python: Cannot construct empty GeoDataFrame with columns

My script import geopandas as gp test = gp.GeoDataFrame(columns=['geometry', 'costs']) the error: File "/usr/local/lib/python3.7/dist-packages/geopandas/geodataframe.py", line 89, ...
1
vote
1answer
22 views

How to ensure the values set in the CSV are captured within the GeoJSON feature values when merging CSV attributes into a GeoJSON

I create a GeoJSON but the merged values are null. The length of the datasets do not match -- is this a potential issue? If so, how do I merge for all covid matches. (FYI this isnt Covid19 related COV ...
1
vote
0answers
41 views

Field length in geopandas shapefile output

I am converting an excel sheet to .shp via pandas i.e. I have a dataframe with 150+ columns and ~900 records (increasing by about 50 every day), that I convert to geodataframe and export to shp: ...
1
vote
2answers
19 views

Geopandas and Matplotlib Plotting error

I am trying to plot a point on top of a shapefile. the Coordinates of the point are accurate. I verified it using the go to XY tool of ArcMap. but when I try to plot overlay using Python the location ...
1
vote
0answers
19 views

Return Geometry in a Pandas Dataframe Google Earth Engine

I have found some sample code that returns features from a GEE image to a pandas dataframe based on specific points in my feature collection. The challenge is I need the geometry on these points to be ...
1
vote
0answers
42 views

How to download buildings data from OSM with a polygon (shapefile) as the bounding box?

I am struggling to complete this task. I am trying OSMnx which can be used to download data from OSM above however I am getting an error when using its from_polygon feature when trying to download ...
1
vote
1answer
53 views

Dump multiple geometry columns of a GeoDataFrame to Features in a FeatureCollection (GeoJSON) instead of properties?

I have a GeoDataFrame with some of its attributes that are geometries (only the position is the one which was interpreted as the active geometry when loading the data from PostGIS): import psycopg2 ...
1
vote
0answers
55 views

Passing dynamic query parameters to an SQL query string in GeoPandas read_postgis() method

Up to now, I used to query geospatial tables with psycopg2 and then convert the geometries to my needs using, e.g. Shapely. Per the psycopg2 documentation, you never format your query string yourself. ...
1
vote
0answers
37 views

Geopandas .difference between two different shapes produces empty difference

I have been puzzled by this, and I feel like it's a geopandas bug. base = gpd.GeoSeries(dist_to_remove).plot(edgecolor='black', color='yellow') gpd.GeoSeries(prec_shape).plot(ax = base, color='red', ...
1
vote
0answers
15 views

Attribute network features (lines) with data from their endpoint

Goal To prioritize water lines in a network based on the building they service Detail I have a shapefile of water lines in a region. The lines are split at their vertices and form a network (more or ...
1
vote
0answers
45 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 | ...
1
vote
1answer
131 views

How to create a raster delineating all drainage basins using pysheds python

I am going through the tutorial of "Pysheds" available in the following website https://www.hatarilabs.com/ih-en/elevation-model-conditioning-and-stream-network-delimitation-with-python-and-...
1
vote
0answers
24 views

Calculating ratios between two shapefiles

So I have two shapefiles, one is a grid and one is a map of the world's land. I am trying to find the ratio of land in each cell of the 'grid' shapefile to show the land/water ratio but I'm stuck. ...
1
vote
0answers
87 views

Getting the center point of a cluster in Pandas

I have a list of of coordinates that have areas mapped out as follows import pandas as pd import numpy as np import folium from folium import plugins from folium.plugins import HeatMap import pyodbc ...
1
vote
0answers
115 views

Unable to get the correct tiles using `bounds2img` via contextily and geopandas for USA

The main idea is to get a png/jpg image file as a basemap for the complete bounds of a geodataframe. The geodataframe here happens to be a map of the USA which I took from the topojson/us-atlas ...
1
vote
0answers
50 views

GeoPandas Overlay Intersect not intersecting some areas

I have a GeoDataFrame where I want to get all intersection between the polygons comprised in it. The cope i use for this is this: intersection_list = [] for index in input_gdf.index.to_list(): # ...
1
vote
1answer
46 views

Find vertices of LineStrings within Polygon - Shapely

I would like to use Shapely to find the vertices that are located within the boundaries of a Shapely Polygon. So far, I could only manage to get it running by converting the LineString and the Polygon ...
1
vote
0answers
52 views

Differences in calculating area of a shape between QGIS and GeoPandas

I'm trying to understand how to calculate the correct area for a shape. I'm well aware from many of the searches that I need to select the right CRS to be able to calculate the right area, but my ...
1
vote
0answers
40 views

Open only part of a GeoPackage layer with a certain geometry type in GeoPandas

I have a GeoPackage (743 MB, zipped) that has one layer, but two geometry types inside that layer (Point and Polygon). When I open the file in QGIS 3.10, QGIS presents a dialogue to me that lets me ...
1
vote
1answer
70 views

Get geopandas geo or affine transform

Does anyone know how to get the affine transformation from a geopandas dataframe? I need this for rasterising geospatial vector data with rasterio. shapes = ((geom,value) for geom, value in zip(...
1
vote
0answers
46 views

Packaging geospatial libraries for cross-platform application, or using docker container?

I am developing some python tools to help some less technical users process geospatial imagery. They generally need to do simple stuff like compress images, reproject images, etc. The users will be on ...
1
vote
0answers
39 views

How to deal with flawed line geometries in Geopandas?

I have a big dataset containing line-geometries. I would like to delete overlapping lines using the intersection statement in geopandas overlay in the following manner: import geopandas as gpd from ...
1
vote
0answers
44 views

Aggregating data and displaying counts with GeoPandas

I have two datasets that I want to use. The first is a shapefile of King County that has polygons broken up by school districts. It has boundaries saved as polygon features on a geo-dataframe. The ...
1
vote
0answers
37 views

Testing for spatial autocorrelation in residuals of OLS regression

I'm currently working on a dataset that is most likely to have spatial autocorrelation issues. In particular, I have observations at the region level and I'm trying to run a regression to check ...
1
vote
0answers
32 views

Finding “most frequently intersected area”?

I have a geodataframe that contains geometries of droughted area for several years. To identify consistently droughted areas, I want to find areas that are droughted for the largest number of years. ...
1
vote
0answers
168 views

How to extract lat, long coordinates from Geography type column in dataframe using SQLAlchemy?

This is the SQL command that works perfectly. SELECT lonlat, ST_Y(lonlat::geometry) AS latitude, ST_X(lonlat::geometry) AS longitude This is the output of the SQL command. lonlat ...
1
vote
0answers
107 views

How to write to geopandas dataframe directly to (Google) Cloud Storage?

I would like to write a geopandas.Dataframe directly to (Google) cloud storage, from the documentation fiona enables this, however I am not sure how to supply the correct **kwargs for the geopandas....
1
vote
1answer
57 views

Aggregating DateTime and GPS latitude/longitude

I have a dataframe with multiple columns including SerialNumber, DateTime, GPS latitude and GPS longitude. Background: Tractors marked with Serial numbers are working(driving) on fields, sending data ...
1
vote
0answers
171 views

geopanda plots / scale in km bar

how to set such scale in km on a map in geopandas as in the picture below. I am using geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres')) map. thanks
1
vote
0answers
220 views

GeoPandas fill polygon gap according to gap area

I have several polygons with holes and I would like to fill the gaps with sizes smaller than a certain area import geopandas as gpd from shapely.geometry import Polygon # Initializing a polygon with ...
1
vote
0answers
257 views

Changing CRS of GeoJSON

I'm trying to change the CRS of a dataset loaded from GeoJSON. input: { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features":...
1
vote
0answers
290 views

Viewing GeoPandas Dataframe in VScode or PyCharm like Pandas Dataframes

I'm not sure if this is a missing feature or something that I couldn't figure out so I wanted to get some help; I started learning geopandas library, now I'm following some tutorials I realized that ...
1
vote
1answer
34 views

Aggregate data from source value to mask layer by overlapping area

Let's assume I have a georeferenced data set seed_layer.geojson and a mask layer leech_layer.geojson. test_leech.geojson: { "type": "FeatureCollection", "features": [ { "type": "Feature", "...
1
vote
1answer
203 views

Create LineString from lat/lon coords form CSV. with beginning and ending lat/lon?

I am iterating through a CSV file of tornadoes, and for each row getting the beginning lat, beginning long, ending lat, and ending long. and trying to plot their line geometry on a map. I got the ...