Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
97 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
1answer
85 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
1answer
368 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
51 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
231 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 ...
4
votes
0answers
253 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
217 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
371 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 ...
2
votes
1answer
486 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. ...
3
votes
1answer
196 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 ...
2
votes
1answer
342 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
1k 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
20 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
293 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
1answer
506 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
1answer
134 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
137 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
2answers
622 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
548 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
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 ...
0
votes
1answer
249 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 ....
3
votes
1answer
10k 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 ...
4
votes
1answer
1k 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) ...
1
vote
1answer
148 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
177 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
407 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
148 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
415 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
423 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
1answer
64 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
4k 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
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,...
3
votes
5answers
668 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
48 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 ...
2
votes
1answer
494 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
269 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
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 ...
5
votes
1answer
5k 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 ...
1
vote
1answer
1k views

python mask netcdf data using shapefile (xarray & geopandas)

I am using the following packages: import pandas as pd import numpy as np import xarray as xr import geopandas as gpd I have the following objects storing data: print(precip_da) Out[]: <...
1
vote
1answer
148 views

Import a shapefile with the needed CRS only if you are going to export it with that CRS?

In GeoPandas is there any need to read in a shapefile with its coordinate reference system or is it only the exporting that requires that a coordinate reference system. shp1= gpd.read_file(i[1],...
3
votes
2answers
1k views

Transfering from pandas dataframe to Geopandas?

I am not able to transfer a pandas dataframe column with geolocation coordinates into a Geopandas Point format. location = pd.read_csv('City_addresses') print location['Geolocation'].head() Outputs ...
2
votes
1answer
504 views

Export Shapefile with UTF-8 encoding for non-english characters in GeoPandas? [closed]

This part of code puts the EΞ characters in a column and when exported it shows ?? in their place. dff['KAEK']=dff['CAD'].str[:5].add('ΕΞ').add(dff['CAD_AD_F'].str[5:]).add(dff['rank']) dff.to_file(...
2
votes
1answer
589 views

Accessing certain column of attribute table of shapefile and renaming it using GeoPandas?

Currently, I am working on converting some R code into python for someone. This person is taking the shapefile and removing all columns except for a select few and renaming them: ec <- readOGR(".",...
0
votes
1answer
1k views

Iterate over geopandas dataframe returning nearest point on each LineString

I'd like to iterate through a GeoDataFrame that contains a column of LineStrings and return a list of points; one from each LineString that is closest to a reference point. #### . Import data from ...
2
votes
0answers
355 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\\...
0
votes
1answer
426 views

How to display large geospatial data in a jupyter notebook with style and tooltip?

I have a large amount of data stored on a postgreSQL database (RDS) with the PostGIS extension enabled. We are currently doing quality assessment of the data and therefore I would like to inspect/...
2
votes
0answers
220 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 ...
0
votes
1answer
78 views

Geopandas script won't perform overlay calculations

I have a txt that contains in each line a sentence like this: INT_ASTIK_EAS ER_ASTOM_ASTIK and so on. I want to ask for a directory of the main folder that contains the subfolders that each contain ...
0
votes
0answers
233 views

Read file form txt and perform operation by name in geopandas

I have a txt that contains in each line a sentence like this: INT_ASTIK_EAS ER_ASTOM_ASTIK and so on. I want to ask for a directory of the main folder that contains the subfolders that each contain ...
1
vote
1answer
116 views

time precision in geopandas read_file

Geopandas read_file reads my time field with less precision. How can I make it the same as my file? I created a file with geopandas to_file(filename, driver='GeoJSON') and it is something like this: ...