Questions tagged [geopandas]

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

120 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
403 views

Geoalchemy: insert 3D elements in PostGIS database

I have shp files that I would like to insert into a PostGIS database. I'm planning to use Geoalchemy2 and geopandas to do so. However, my data have the geometry types LINESTRING Z and POINT Z. As I ...
4
votes
0answers
290 views

Wrong reprojecting of a shapefile with to_crs in GeoPandas

When reprojecting an ESRI Shapefile (EPSG:21781) into an EPSG:4326 with QGIS and then importing the resulting file in GeoPandas and plotting it, the coordinates are correct. When importing the same ...
4
votes
0answers
2k views

Using polygons to create mask on 2d grid with Python?

I have some polygons (Canadian provinces), read in with GeoPandas, and want to use these to create a mask to apply to gridded data on a 2-d latitude-longitude grid (read from a netcdf file using iris)....
4
votes
0answers
333 views

What's the fastest way to convert large csvs to point shapefile

I'm working in QGIS, and my current method to change csvs to shapefiles is to import them to QGIS, right click and save as shapefile. For large CSVs (over 100 million rows) it can take quite some time ...
3
votes
0answers
44 views

Nearest neighbour joins for two geodataframes using KDtree from scipy/sklearn

I have a number of large geodataframes and want to automate the implementation of a Nearest Neighbour function using a KDtree for more efficient processing. The process I want to achieve here is to ...
3
votes
0answers
312 views

Multiprocessing with geopandas

I am learning how to implement the multiprocessing with spatial data using the module multiprocessing. I am trying to implement a spatial intersection between a polygon file and a grid file. I am ...
3
votes
1answer
553 views

Creating shapefile file with Fiona and GeoPandas?

I am trying to create a shapefile and a geojson using geopandas and fiona. import fiona import fiona.crs ... geometry = [Point(xy) for xy in zip(df['longitude'],df['latitude'])] crs = {'init': '...
3
votes
0answers
136 views

Memory errors when doing Zonal Statistics on a multi polygon shapefile in Python

I want to calculate the mean NDVI with the EthNdvi.tif file for each zone (there are around 650 admin zones) in the the woreda shapefile. I'm having some issues with running the following lines of ...
3
votes
0answers
2k views

Folium heatmap not displaying

I have an output file data.json [{"5403": 2, "9734": 1, "2565": 5, "5087": 2, "9061": 1, "1761": 4, "4811": 7 "1111": 5, "3891": 3, "1962": 3}] and a shapefile converted to geojson https://www....
2
votes
0answers
32 views

Add WMS to matplotlib Python

Currently I am adding a basemap from stamen.com to my plots as it is explained here: http://geopandas.org/gallery/plotting_basemap_background.html . Is it also possible to load a WMS from another ...
2
votes
1answer
72 views

GeoPandas: Get distance from geom in tableA to a geom in tableB that matches attribute from tableA

UPDATE WITH SOLUTION (at bottom) Using GeoPandas I am trying to identify the distance between an election candidate's home address (Point) and the electoral district they are running in (Polygon). ...
2
votes
0answers
50 views

GeoPandas spatial join generates error in QGIS 3.8 Python console

I want to execute a spatial join using GeoPandas in the Python console QGIS 3.8 like this: dfsjoin = gpd.sjoin(point, polygon) but it doesn't work. It always shows the following error: Exception ...
2
votes
0answers
35 views

Plotting Geopandas Gallery example fails?

I have been having trouble getting the figures from the example provided in Geopandas Gallery examples. When I ran these scripts in Jupyter console: import geopandas import geoplot import matplotlib....
2
votes
0answers
184 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
532 views

Overlay Union Geopandas improve performance

How to speed up the "union" of two shapefiles using geopandas? I have two large shapefiles: geodataframe_left.shape = (3610, 12) (500 MB) (link) geodataframe_right.shape = (16396, 3) (200 MB) (link)...
2
votes
0answers
295 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
3k 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
278 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
402 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
239 views

TopologyException issue when doing intersection in Geopandas?

When I do overlay processes like intersection, I mostly get: :TopologyException: found non-noded intersection between LINESTRING (229971 4.39944e+06, 229971 4.39944e+06) and LINESTRING (229971 ...
2
votes
0answers
218 views

GeoPandas causing issues with PyQGIS standalone

I have a code where I would like to be able to use both GeoPandas and PyQGIS. However, it seems that including GeoPandas is causing issues in the output of PyQGIS. Here is a small illustration using ...
2
votes
0answers
408 views

draw map scale in geopandas

Is there a geopandas version of basemap's m.drawmapscale function? If not, can I somehow utilize basemap's drawmapscale function within geopandas?
2
votes
0answers
2k views

Create custom color map for multiple GeoPandas plots to share same scale

My objective is to create a 2x2 figure where each cell in each grid is on the same color scale. Currently, I haven't found a compound plot option in GeoPandas that allows me to plot one GeoDataFrame ...
2
votes
0answers
338 views

Optimize computation distance of million points to lines in Python

I have found questions here of how to compute the distance of a point to a line (manually, with distance method of some libraries...) but my problem is that I need to compute the distance of 4M points ...
2
votes
0answers
271 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
2k 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: ...
1
vote
0answers
18 views

Get all road intersecting a polygon

I am trying to read from a local instance of the OpenStreetMap database all roads intersecting a boundary coming from another database. I actually get a result with the following piece of code: #...
1
vote
0answers
21 views

How remove a duplicated coordinate in multipoints using GeoPandas?

I have shapefile river data in line format, import this data with GeoPandas and apply it to a .boundary to get as initial and final coordinates of each line. But as lines intersect a coordinate may ...
1
vote
0answers
30 views

Making polygon for every point in set using voronois?

I'm trying to make polygons from points, were each point will be represented by one polygon. I tried using voronois, but the results are incomplete. While I more or less understand where this ...
1
vote
0answers
49 views

GeoPandas transform latitude/longitude coordinates to UTM coordinates

I have a shapefile which I read with GeoPandas, this shapefile has lat/long coordinates and I want to transform it to UTM coordinates. I tried this: shapefile = gpd.read_file('example.shp') #CRS = ...
1
vote
0answers
36 views

Merging adjacent polygons using Geopandas by avoiding filling gaps

I have raster dataset that I would like to convert into vector polygons. Raster to polygon conversion works pretty good. But, having problem when I try to merge adjacent polygons using Dissolve ...
1
vote
0answers
29 views

Adding distance when buffering point geometry in a geodataframe?

I have 2 geodataframes that I want to combine. They the same fields/columns but different geometries (one is points, one is polygons).To do this I want to buffer the points slightly (like 10m or ...
1
vote
0answers
50 views

Create a geodataframe with more than one 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
1answer
84 views

Finding shortest distance from point(s) to number of polygons at varying angles using shapely?

My aim is to calculate the distance a point is from land in Python, trying to replicate the functionality of fetchR. Given an origin and distance, I create shapely LineStrings which radiate out from ...
1
vote
0answers
235 views

Geopandas simplify results in gaps between polygons

The goal is to simplify the geometries of a shapefile containing multipolygons. However, when I use Shapely's simplify in geopandas, the result contains gaps between the polygons. I was hoping that ...
1
vote
0answers
251 views

Changing CRS of geometry in geopandas dataframe efficiently?

I have a shapefile which I am converting into a geopandas dataframe. The CRS of this shapefile is epsg:4326 and I want to convert this to epsg:3857. import geopandas as gp file_path = 'zip_poly.shp' ...
1
vote
0answers
558 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 ...
1
vote
0answers
69 views

Most effective way to find spatial relationships in python

I am trying to find the spatial relationship between two polygon geoDFs as follows: Find geoDF1.geom within geoDF2.geom else (not within) Find geoDF1.geom with largest intersection fromgeoDF2.geom ...
1
vote
1answer
240 views

How to identify unique attributes in a column and add them as separate columns and perform spatial join sum in python

I need to extract all unique values from the "CATEGORIES" column from shapefile 2 (from the Shapefile and its data frame is shown below) and add them as columns to the Shapefile-A data table (see ...
1
vote
0answers
342 views

Reading data to geopandas using WFS - GML format

This relates to the question here: Reading data to geopandas using WFS? Is there a way to to do the same with a service that does not supply the data in GeoJSON format, but in GML-format? The ...
1
vote
0answers
270 views

GeoPandas geocode error when using Nominatim

I am following this lesson about Geocoding. I have entered: # Import necessary modules import pandas as pd # Filepath fp = r"addresses.txt" # Read the data data = pd.read_csv(fp, sep=';') data....
1
vote
0answers
33 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?
1
vote
0answers
244 views

Overlay two linestring objects in geopandas, accounting for the attributes

This is a follow up to Intersecting MultiLinestring based geodataframes with geopandas? in which I was trying to intersect polyline layers and carry the attributes over to a resulting overlay/...
1
vote
1answer
636 views

Geopandas not recognizing geometry type

I am trying to write a point in polygon spatial join to file by county. In my code I read in a geojson object of building polygons for a whole state, grab the centroid and split the centroid points by ...
1
vote
0answers
120 views

geopandas - which files to use?

I'm new to geopandas and want to analyse a Geodatabase. The information I received contains a zip archive of 45 files, containing 17 ATX files - each 5KB 2 files without extension - each 1KB 7 ...
1
vote
0answers
194 views

Split geopandas DataFrame evenly by distance

Is it possible to split a geopandas DataFrame that contains LineStrings in evenly spaced segments? I have a DataFrame loaded from a shapefile that contains the track of a railway. I want to project ...
1
vote
0answers
520 views

Dividing Geographical region into equal sized grid and retrieving indexing position

I have GPS coordinates of human mobility in Beijing Area. I want to divide geographical space in to rectangular grid, for example 2 sq. km (delta), and access the indexing position of any point inside ...
1
vote
0answers
62 views

Set tolerance for intersection in Geopandas?

I want to set tolerance 10^-8 for the intersection. inte_s=gpd.overlay(shp,shpa,how='intersection') How can you do that?
1
vote
0answers
363 views

Group by index column, compare area and add values to new column in Python?

I have these columns: index, area_of_poly, cad_admin I have to group by index (it is a normal column called index) in order to take the rows that have the same value. #all the ones, all the twos, ...
1
vote
0answers
1k views

NameError: name data_all1 is not defined in Python 3.x

I have a standalone script using data opened from a Geopackage with Fiona. When I run this portion of my script: import os import fiona import numpy as np datapath= '/media/sf_SharesShapefiles/' ...