Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [geopandas]

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

0
votes
0answers
30 views

How to query all points within 2000 meters through spatial index in python?

As you can see, I have some data and the projection epsg:4326. For example geometry id 0 POINT (120.681175 27.989723) 1 1 POINT (120.70615 27.97382) 2 2 POINT (120....
0
votes
0answers
16 views

Find best matching polygon in a Geopandas series [on hold]

Say I have a geopandas Series S of different polygons. Furthermore I have a Polygon P. I would like to find the most efficient way to find the polygon in S that overlaps P to the highest extent.
0
votes
1answer
38 views

gdal/geopandas data object compatibility in python

Is it possible to convert an ogr datasource into a geopandas GeoDataFrame without writing the datasource first as a physical file and reading it back? I am referring to something like import ogr, ...
0
votes
0answers
11 views

How to convert from EUREF-FIN to WGS84 in geopandas

Trying to convert ETRS-TM35FIN coordinates in the EUREF-FIN projection to WGS84 in geopandas with this: x = 429300 y = 7084490 df = pd.DataFrame([[x,y]],columns=['x','y']) df['Coordinates'] = list(...
0
votes
1answer
10 views

ValueError: Invalid field type <class 'bytes'>?

This error ValueError: Invalid field type is caused at the last line of this code: fs.to_file(out,encoding='iso8859_7') Full code: q=gpd.read_file(fname + "\ASTENOT\simplify_centerline.shp",...
2
votes
1answer
52 views

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....
0
votes
1answer
23 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 ...
0
votes
1answer
27 views

Generating a raster layer with intersecting line lengths as cell values

I have a polyline vector layer and a template raster dataset. For this polyline vector layer I would like to generate a new raster dataset based on the template raster dataset, but in which each cell ...
2
votes
0answers
39 views

Determining direction of traffic in road network?

I'm working with road segments as LineStrings in GeoPandas, for each segment I would like to determine the direction of travel (they drive on the right). This information is not encoded, how can I ...
0
votes
0answers
15 views

Merging datasets from different timeframes in geopandas

I have two datasets on neighborhoods in municipalities rom two different years. Due to administrative restructuring some data cannot be matched on the given id. When I plot the unmatched data there is ...
0
votes
1answer
14 views

Import PostGis tables into a GeoDataframe unexpected : 'AttributeError: 'NoneType' object has no attribute 'encode''

When I try to import two of my tables from postgis to geopandas I have an error. I guess the problem is due to my geometry columun, but I don't know why. engine = create_engine('postgresql+psycopg2://...
1
vote
1answer
38 views

Joining attributes after selecting one polygon which intersects another using geopandas?

To select the polygons which overlap other layer's polygons, I came up with this code based on what I found on this site: import geopandas as gpd import fiona import os import sys # Get the current ...
2
votes
1answer
31 views

British National Grid and WGS84 conversion doesn't match in reverse in GeoPandas/PyProj

When I try to convert Google Map's lat/long into EPSG:27700 and then add a 50-meter buffer, I'm getting unexpected results. I noticed that conversions in pyproj between WGS84 and BNG are not ...
3
votes
0answers
44 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 ...
1
vote
0answers
37 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/...
3
votes
1answer
81 views

Intersecting MultiLinestring based geodataframes with geopandas?

I would like to perform the following operation using geopandas. The segments are delimited by red points and the blue items are attribute information. My inputs are the first and second line ...
1
vote
1answer
62 views

How to calculate mean value of a raster for each polygon in a shapefile

I wrote a Python script who calculate, for rasters, mean value for each polygon of a shapefile. But I think that it's a "war machine" (it takes many treatment time) and I would like to simplify it. ...
2
votes
1answer
29 views

How to process 2 GeoDataFrames by rows pairwise?

I have 2 GeoDataFrames 100 records each, and want to calculate distances between respective geometries (Points, of course). I can't see how to make it other than write a cycle to iterate rows ...
0
votes
0answers
36 views

Converting a geopandas/shapely object geometry to ogr geometry

I use a python package which has many vector operations in-built (https://github.com/dshean/pygeotools/blob/master/pygeotools/lib/geolib.py), but this accepts as input an ogr type geometry object. ...
1
vote
1answer
47 views

Dissolve not based on attribute in geopandas

I would like to dissolve a shapefile regardless of attribute content using geopandas. The regular dissolve can be accomplished with something like this: import geopandas all = geopandas.read_file(...
0
votes
0answers
17 views

Optimize geopandas overlay

I want to calculate the difference between two geodataframes. One of them contains 700k linestrings. I want to get suggestions to optimize the operation in terms of time. difference = geopandas....
0
votes
0answers
161 views

Error in coordinate transformation with Geopandas

I am trying to transform coordinate system of shapefile. %matplotlib inline import matplotlib.pyplot as plt import pandas as pd import geopandas as gpd from geopandas import GeoDataFrame from ...
0
votes
0answers
13 views

How to know the values of a pandas dataframe geometry? [duplicate]

I am trying to read a shp file using geopandas. `gdf = gpd.read_file("AOI_20160625_20160628.shp")` The file is constructed in QGIS, inside there is a simple polygon. I would like to know lat and ...
1
vote
1answer
30 views

How to create a multiple buffer using geopandas

I want to create buffers from any point in a multiple point file. I can do it with a constant buffer using geopandas.buffer() track.geometry = track['geometry'].buffer(0.05) track_line = track....
1
vote
0answers
42 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 ...
0
votes
0answers
31 views

Geopandas fails to transform coordinates from OSGB36 to WGS84

Strangely, geopandas gives the wrong output when trying to transform a geodataframe from the OSGB36 projection (epsg=27700) to WGS84 (epsg=4326): import geopandas as gpd from pyproj import Proj, ...
1
vote
1answer
75 views

Assigning an ID to each pixel which overlaps with polygon shapefile (Python)

I calculated NDVI values for the last 24 years and created Pandas Dataframe which every cell includes columns with XY coordinates and 24 NDVI values. I have several polygon shapefiles which overlap ...
3
votes
2answers
76 views

Coordinate reference system transformation

I am looking to transform the CRS of the geometry from my initial shapefile data to standard lat-long coordinates - espg 4236. Here's the geopandas dataframe: I wrote some script below that ...
3
votes
1answer
62 views

Randomly sample from geopandas dataframe in python

I am reading a shapefile as geopandas dataframe and them using pandas subset method to select a region. geodata = gpd.read_file(bayshp) geodata.dtypes geodata.head(10) OBJECTID FIPSSTCO ...
0
votes
1answer
68 views

turn back shapefile from pandas to geopandas

I have these shapefiles: q=gpd.read_file(a.shp) df=gpd.read_file(b.shp) final = pd.merge(df, q, on=['FID_buffer'], how='inner') #out= a certain directory final.to_file(out) AttributeError: '...
1
vote
0answers
28 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 ...
0
votes
1answer
56 views

Geopandas: importing shp file throws “No dataset found at path” error

I'm completely new to geopandas. I'm trying to follow this tutorial to geopandas and am trying to import the "oceans.shp" file, which I downloaded from here (together with the .dbf, .prj, qpj, and ....
1
vote
1answer
237 views

Create a polygon from coordinates in GeoPandas with Python

I was trying to create a simple Polygon from a list of coordinates and export it to multiple formats (including shapefile and GeoJSON) and wanted to automate it using Python. There were some good ...
2
votes
1answer
49 views

How can I superimpose a geopandas dataframe on a raster plot?

I have a geopandas dataframe countries with country polygons, and a raster dataset raster (read with rasterio). I've already aligned the two as follows: countries = countries.to_crs(raster.crs.data) ...
0
votes
1answer
52 views

Join points to a line with minimal distance

I have a point cloud (x,y) in a random order. Say sorted([(1, 1), (2, 2), (0, 0), (4, 4), (3, 3)]). Is there an easy way to connect them to a simple line like ((0,0),(1,1),(2,2),(3,3),(4,4)) doing ...
1
vote
0answers
26 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 ...
2
votes
1answer
59 views

Sort a geopandas dataframe by location

I have a geopandas DataFrame (created from a shapefile) which represents the course of a public transport vessel. Exemplary DataFrame: | oid | geometry | |-----|---------------------| | ...
0
votes
0answers
28 views

Spatial join in Geopandas is only finding itself

I ran my code successfully last week, cleared the kernel and now it does not work. It must be something simple I'm missing, but I cannot seem to puzzle it out. The purpose of the code is to find all ...
2
votes
1answer
43 views

Extracting GPS points inside the region boundary

I have large set of GPS coordinates of human mobility in different parts of China, but I am only interested in points in Beijing City. These points are in excel csv file that I read into pandas ...
1
vote
0answers
37 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 ...
0
votes
1answer
35 views

Find the number of sides that intersect between two or more polygons

I am currently struggling to find the number of sides that intersect between two or more polygons in a layer, the layer contains around 2700 polygons. All polygons have a rectangular form, as it can ...
2
votes
1answer
614 views

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

So I have turn 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="_") yield <...
2
votes
0answers
349 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,...
3
votes
4answers
133 views

Interchange y, x to x, y with geopandas (python) or QGIS

I realized that the order of my geopandas dataframe is wrong, it has y, x instead of x, y. This makes it difficult to use with other modules that needs exactly x, y type of coordinates. Is there any ...
1
vote
1answer
42 views

Distance mistake during grid creation

I'm working on a script where I create a grid with the bounding box of a geodataframe, a width and a height (they might be equals for a square grid). I don't know why but when I try to make a 10m ...
0
votes
0answers
14 views

Populate a column with part of the unique directory of each file?

I want to add a column and populate it with the part of each files unique address in the directory: Example: say I have two files from each subfolder named: 45554 and 32456 Therefore their paths are ...
2
votes
1answer
72 views

Geopandas spatial join not working

I have two GeoDataframes - one has polygons, the other points. import geopandas as gpd from shapely.geometry import Point area = gpd.GeoDataFrame.from_file('areas.shp') print area.crs {u'lon_0': -...
5
votes
1answer
92 views

How to do snapping in Geopandas?

I want to perform snapping in all the lines of a shapefile that don't connect to the nearest other lines. It would be okay to have a tolerance of 0.5 meters. So between 0.5 it should connect to the ...
2
votes
0answers
48 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
1answer
347 views

Add CRS to a shapefile in Geopandas?

I am trying to add CRS to a shapefile that I am exporting: shp1= gpd.read_file(i[1],encoding='iso8859_7',crs_wkt='2100') shp1.to_file(out,encoding='iso8859_7',crs_wkt='2100') When I import it to a ...