A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [geopandas]

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

135 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
450 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 ...
5
votes
0answers
367 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 ...
4
votes
0answers
78 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 ...
4
votes
0answers
346 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)....
3
votes
0answers
97 views

Find a centerline of an intersection between two irregular shaped polygons

I have two irregular shaped polygons that overlap each other at least in at two points. I want to first find the intersection area between all of them, then for the polygon pair that intersects I want ...
3
votes
0answers
475 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
0answers
717 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)...
3
votes
1answer
719 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
169 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
275 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 ...
3
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 ...
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
48 views

Plotting GoeDataFrame on a raster

I have a bunch of polygons which I loaded from a shapefile into a fields GeoDataFrame: geometry raster_val 0 POLYGON ((8.56799 47.80800, 8.56799 47.77200,...
2
votes
0answers
27 views

Create sequential ID column type when loading GeoDataFrame to PostGIS

Is there a way to define GID column as sequential (auto-incremental) when loading GeoDataFrame (created from Shapefile) to PostGIS? I use Geopandas and "to_sql" method: geodataframe.to_sql(tablename, ...
2
votes
0answers
203 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 = ...
2
votes
0answers
90 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
151 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
64 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
47 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
1answer
282 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 ...
2
votes
0answers
262 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
720 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
377 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
313 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
470 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
277 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
526 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
612 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
302 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
50 views

GeoJSON as string to GeoPandas geometry Python

I have this (subset) Pandas dataframe: I read it from an XLSX file. I would like to convert it to geopandas GeoDataFrame. In order to do so, I need a valid geometry column. The GeoJSON column in my ...
1
vote
1answer
33 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 ...
1
vote
2answers
37 views

Loading GeoDataFrame to PostGIS when GEOM column contains MULTILINESTRING and LINESTRING

How can I load GeoDataFrame (populated from shapefile) to PostGIS when GEOM column contains MULTILINESTRING and LINESTRING e.g.: LINESTRING (14.2384666 46.6304714, 14.2386703 46.6304123) ...
1
vote
0answers
47 views

Generating transects perpendicular to Shapely/Geopandas Line

I'm doing an analysis on transects going perpendicular to a 1000m topographical contour line and I'm struggling to find a good way to create evenly spaces transects perpendicular to that contour. As ...
1
vote
0answers
29 views

Calculate distance in meters using results in degrees

I receive some distance differences in degrees, like this: 0.0009698680322606666 using this function: def radius(gpd_df, cpt, radius): sindex = gpd_df.sindex bbox = (cpt.geometry.x-radius, ...
1
vote
0answers
22 views

Pathfinding in mixed network

I have three geopandas GeoDataFrame representing a road network, telecommunication wires and a set of network devices to be connected to the network. They are respectively depicted as yellow lines, ...
1
vote
0answers
205 views

Python: distance of point to polygon border

I want to measure the distance of a point(lat,long) to a the border of a Polygon. So I have created the polygon with the coordinates. from shapely.geometry import Polygon, Point Polygon(zip(lon_list, ...
1
vote
0answers
38 views

Legend of GeoDataFrame does not sort categorical data values

I try to plot a map of temperature with geopandas in Google Colaboratory. This is my dataset: id = '1LOywA8JPP6vOFDP-CBOBgkSmX7zv2pDc' downloaded = drive.CreateFile({'id':id}) downloaded....
1
vote
0answers
26 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
41 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
73 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
47 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
42 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
109 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
0answers
510 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
539 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
99 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
0answers
254 views

Write feature collection to S3

Is there a way to write a feature collection from Python memory to an S3 bucket (as Esri Shapefile, zipped Shapefile or something else) without writing it first to disk? I tried writing to a ...