Questions tagged [geopandas]

GeoPandas is an open source project to make working with geospatial data in python easier.

107 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
367 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
254 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
317 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
34 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
260 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
469 views

How to create the prj 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
114 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
26 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
126 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
449 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
252 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
2k 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
263 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
357 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
221 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
336 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
1k 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
299 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
250 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
25 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
31 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
63 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
107 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
150 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
341 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
56 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
209 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
291 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
244 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
31 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
1answer
494 views

Perform sjoin in geopandas leads to:'AttributeError: 'GeoSeries' object has no attribute 'columns''

I try to find all the polygons in a dataframe thant intersect an other dataframe (made by buffering my polygons) usign sjoin. First I did the buffers gdf['geom_buf'] = gdf.geom.buffer(100) Then I ...
1
vote
0answers
218 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
514 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
109 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
178 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
430 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
60 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
335 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/' ...
1
vote
0answers
181 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 ...
1
vote
0answers
368 views

How to fill the color in choropleth map in absolute value?

Problem I am planning to publish an article about 'how many votes are counted in each region' every one hour after the June election in Korea is over at 6 p.m. So at 7 p.m., at 8 p.m., at 9 p.m.,...
1
vote
0answers
510 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 ...
1
vote
0answers
253 views

How to Clip raster using shapefile and store each shape as a numpy array

I have a raster file in numpy array of size 4x9000x10000. The raster file has 4 bands - Red, Green, Blue, NIR and 6 different crop types. I want to create small arrays of size, say 4x100x100 such ...
1
vote
0answers
217 views

Join multiple Points to Polygon and concatenate joined point values of column into Polygon column

My data: Points: ID HN Street 1 5 Examplestreet 2 6 Examplestreet 3 2 Otherstreet 4 2 Anotherstreet Polygons: Name Firstpolygon Secondpolygon Otherpolygon ...
1
vote
0answers
195 views

Why GROUPBY doesn't work?

I don't know why but pandas groupby doesn't work in this case whereas I used it well in other scripts. All lines are still there after it. This is my code: all_points['WKT'] = all_points['geometry']...
1
vote
0answers
54 views

Confirming coordinate system/shapefile is correct?

I am using Census Shapefiles from NHGIS. I am trying to convert points from it to easy to read latitude and longitude - but am having some trouble. The sample data I'm using for now is data from ...
1
vote
0answers
277 views

Plot the spatial join shapefile boundary in Python

I have two spatial object Geo_TWS is a shapefile boundary, geo_cell is points and already convert to GeoPandas. base = Geo_TWS.plot(color='white', edgecolor='black') geo_cell.plot(ax = base,...