The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
23 views

How to apply the orient function on the geometry of a GeoPandas dataframe

Given a GeoDataFrame where the geometry column contains both Polygons and MultiPolygons. How can I force the orientation (left-hand-rule or right-hand-rule) on these geometries?
7
votes
3answers
10k views

Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'

I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices. The problem is that ...
1
vote
0answers
39 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, ...
0
votes
0answers
35 views

Cannot create geodataframe from feature class due to IndexError: list index out of range

I have a function that helps me read in large feature classes and them create a geodataframe: line_feat = "S_Studies_Ln" cnms_cols = ['REACH_ID', 'STUDY_ID', 'CO_FIPS', 'CID', 'FLD_ZONE', '...
0
votes
0answers
69 views

Coordinates format [closed]

How to read this Point(601872.0567818936 5789972.687450857)? This point is consist of latitude and longitude. So I need to know how can I convert that to Degrees and Minutes? Another example of the ...
0
votes
0answers
20 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
1answer
246 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 ...
0
votes
1answer
86 views

Why do I get error “Runtime: b'no arguments in initialization list'” when running to_crs?

I have a geopandas dataframe that has POINT geometry in NAD83. I want to use to_crs to change them to espg: 4326. When I first bring in the feature class as a gpd dataframe, it shows no crs, so I use ...
2
votes
1answer
76 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). ...
1
vote
0answers
39 views

Distance between centriod of the polygon and each and every point of the polygon [closed]

I'm trying to calculate the distance between centriod of the polygon and each and every point of the polygon using GeoPandas Python I need to find the distance between centroid(18.9568383649 72....
1
vote
0answers
23 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: #...
2
votes
2answers
57 views

Get field names in attribute table with Python

I have a geopackage file, with a layer called "MyLayer". Within this I have an attribute table with approx 20 attributes. I can read in each attribute individually like: import geopandas as gpd ...
1
vote
0answers
24 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 ...
2
votes
1answer
41 views

Calculating area of geometry using Geopandas? [duplicate]

Is there an easy way in geopandas to calcuate polygon areas after an intersection analysis? I am switching from ArcGIS to open source and try to translate my code. In ArcGIS I used: arcpy....
0
votes
1answer
29 views

Mask rasterio raster with geopandas shapefile

I am loading a shapefile using geopandas as follows: import geopandas as gpd StudyA = gpd.read_file('.../Study_Area_Polygon.shp') Next, I am using folium to plot it interactively: m = folium.Map([...
1
vote
1answer
657 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 ...
3
votes
1answer
567 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': '...
5
votes
1answer
409 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 ...
1
vote
0answers
35 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 ...
0
votes
1answer
177 views

Length of intersections from a linestring and a grid shapefile by using Python GeoPandas & QGIS

I am using Python GeoPandas and I have two shapefiles. One of them is a grid file containing equal polygons. The other shapefile is a linestring file with several lines and its Attributes. The idea ...
1
vote
1answer
26 views

Turn detached coordinate values into linestring in GeoPandas

I have the following dataframe id x1 y1 x2 y2 0 431634.751688 4.581910e+06 431692.792776 4.581814e+06 1 431930.133825 4.581873e+06 431938....
1
vote
0answers
53 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 = ...
4
votes
2answers
10k views

Filter a GeoPandas dataframe for points within a specific country

I have a dataframe of health survey data which is geotagged, called momdata. I have converted the dataframe to a GeoPandas dataframe, and used the geotags as the geometry column within the dataframe, ...
2
votes
0answers
34 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 ...
1
vote
1answer
75 views

Dataframe of points to PostGIS

I have a csv file with some info and coordinates and I want to create a table in PostGIS with that CSV file. This is what I have so far: import pandas as pd import geopandas from datetime import ...
3
votes
3answers
90 views

Colorizing polygons based on color values in dataframe column?

I preparing some choropleth election result maps in Geopandas. The assigned color for each electoral district must correspond with the winning party (a color that I pre-determine), and the intensity ...
2
votes
1answer
42 views

Truncating points precision

I have geopandas with CRS in meters (ITM {'init' :'epsg:2039'}). I converted the geometry from espg:4326 so I have very high precision which I don't require: POINT (177559.4776412862 594546....
0
votes
1answer
38 views

geopandas overlapping check

How we can check if feature has intersections or not with other features in one shapefile data, I wanna make sure if in that file there is no overlaps between polygon, I have read this approach "An ...
0
votes
0answers
48 views

Getting more precision with GeoPandas?

Geopandas Reading a shapefile with GeoPandas and printing its total bounds: dataframe = gpd.read_file('example.shp') print(dataframe.total_bounds) Prints: [ 663590.5817 1541419.8307 724630.0589 ...
0
votes
0answers
27 views

Memory usage (or absolute bytesize) of geometry objects(shapely) in a GeoDataFrame in Python?

I am currently working on analyzing data structure and size of a shapefile. To analyze it, I was wondering how much geometry column consumes the size of a shapefile. Unlike other features, geometry(in ...
0
votes
0answers
28 views

Using Single Polygon for entire dataframe in PySAL?

I'm trying to calculate the queen contiguity weights using pysal's queen_from_shapefile() helper method based on this page Not being a GIS specialist I wanted to check my intuition on this Q&A ...
3
votes
1answer
107 views

Convert contours to polygons maintaining attributes using Python?

I have a series of polylines(contours) that i want to convert to polygons using Python (GeoPandas, Fiona, Shapely). Because these are contours, there will be donut polygons, can anyone point me to how ...
2
votes
1answer
63 views

How to dissolve overlapping polygons using GeoPandas

Assuming the following: from shapely.affinity import translate from shapely.geometry import Polygon import geopandas p0 = Polygon( [(0,0), (2,0), (2,2), (0,2)] ) p1 = translate(p0, xoff=1) p2 = ...
2
votes
1answer
52 views

Accessing a ShapeFile with GoogleEarthEngine-API : Invalid GeoJSON geometry

I'm trying to download Sentinel-2 data of my area of interests on Google Earth Engine API for Python. I'm trying to access my shape file (contains 2 different polygons) on the API. I added the shape ...
3
votes
1answer
48 views

GeoPandas not projecting from 4326 to a UTM zone properly?

I am at my wit's end trying to figure out why my data is not being reprojected properly in a geodataframe. Given this input data, saved in a variable called power_lines: {'type': 'FeatureCollection',...
0
votes
1answer
149 views

Equivalent method for .withcolumn() for geodataframe

I am trying to use a user-defined function in pyspark in order to check whether the points in CANmep_GDF lie within the polygons in gda_GDF. from geopandas import GeoDataFrame def check_exist(geom):...
41
votes
2answers
37k views

Convert a pandas DataFrame to a GeoDataFrame

This seems like a simple enough question, but I can't figure out how to convert a pandas DataFrame to a GeoDataFrame for a spatial join. Here is an example of what my data looks like using df.head(): ...
1
vote
1answer
66 views

Get UTM zone with GeoPandas from a shapefile

I want to know to which UTM zone belong a shapefile. With GeoPandas I can read a shapefile and know its EPSG code: import geopandas as gpd dataframe = gpd.read_file('shapefile.shp') print(dataframe....
2
votes
0answers
52 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 ...
0
votes
1answer
231 views

Spatial overlays : Union between multiline and multipolygon with geopandas

I try to overlays (apply union) my multipolygon on the multiline with GeoPandas, but it seem like the GeoPandas overlay function work only with (Multi)polygon. Is there any way to make that with ...
0
votes
0answers
42 views

Cannot open gdb folder from external drive using geopandas

I am trying to open a .gdb folder from an external drive with geopandas: import geopandas as gpd data = gpd.read_file('/Volumes/SSD/data.gdb') and I am getting the following error: DriverError: '/...
1
vote
1answer
74 views

Plotting a heat map onto background in python using kde?

I have a geodataframe with points within the united states. Each point has a geometry attribute as well as a value. I would like to plot a heat map based on these values on top the map of the united ...
0
votes
0answers
22 views

GeoPandas Dissolve splits polygons into parallel strips?

I have polygons that is converted from raster dataset with Raster Pixels to Polygons in QGIS. I would like select some polygons based on the attribute value and merge them using Dissolve function in ...
2
votes
1answer
493 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
1answer
447 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
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 ...
0
votes
1answer
28 views

Getting z coordinates from polygon list of Geodataframe?

I am using Python to solve a problem with many polygons that could be really stressful with other software related to my field (mining), however i havent found a way to extract the Z coordinates from ...
0
votes
1answer
65 views

Creating polygons from centroids in Python for an interactive map?

I have a geopandas dataframe where each record is a point. I am making an application using Flask and Python and would like to display an interactive map in HTML where the points would be transformed ...
0
votes
1answer
495 views

Python geopandas dataframe of polygons — determine nearest neighbor polygon?

I am trying to figure out how to dynamically create expanded regions of interest based on polygon geometries in geopandas until some threshold is satisfied (essentially custom regions across the ...
0
votes
2answers
48 views

GeoPandas sjoin with extensive quantities

I have one geodataframe that contains polygons and corresponding land use category (e.g. agricultural, commercial, retail, residential, ...) and another that contains census tract polygons and ...