Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
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, ...
3
votes
0answers
73 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 ...
5
votes
1answer
7k views

Changing colours in GeoPandas?

I have a very simple map (http://www.nyc.gov/html/dcp/download/bytes/nybb_15b.zip) and I have never before worked with shapefiles in any way. Can someone tell me what I need to do in order to change ...
3
votes
2answers
72 views

GeoPandas cut lines with polygon

I wanted to clip lines with polygon geometry: from shapely.geometry import Polygon, LineString import geopandas as gpd polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) line1 = LineString([...
0
votes
0answers
24 views

Is it possible to create a GeoJSON file with a defined geometry type but no features using Python?

I would like to initialize many empty GeoJSONs that have a defined geometry type (i.e. polygon or polyline) but contain no actual geometries. I would also need to set the CRS via an EPSG code. After ...
0
votes
1answer
144 views

Reading in AW3D30 GeoTIFF files and processing them in Python?

I am new to GIS processing, and I am using Python 3.6 to do so. My current task is to read in several files of geographic data (specifically tiles of elevation data from JAXA), combine them for my ...
1
vote
1answer
21 views

Plotting shapes form Census Bureau with GeoPandas results in some erroneous white triangles

GeoPandas 0.6.1 Almost every shapefile from Census Bureau is giving the same error. In this case is the Block data shapes from Maine. The file is "tl_2019_23_tabblock10.shp" gdf.plot(figsize=(32, ...
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, ...
0
votes
1answer
40 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?
8
votes
3answers
11k 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
95 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
57 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
32 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....
0
votes
1answer
486 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
115 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
46 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
24 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
67 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
32 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
70 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....
1
vote
1answer
798 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 ...
5
votes
1answer
431 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
59 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
231 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
28 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....
2
votes
0answers
143 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 = ...
5
votes
2answers
12k 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
65 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
114 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
220 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 ...
3
votes
1answer
66 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
56 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
54 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
49 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
31 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
197 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
115 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
90 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
76 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
201 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):...
42
votes
2answers
39k 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
98 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
58 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
285 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
71 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
203 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
27 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
614 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
487 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
44 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 ...