Questions tagged [geopandas]
an open source project to make working with geospatial data in Python easier.
820
questions
6
votes
2answers
126 views
Self split geopandas Linestring geodataframe in a fast way without loosing all attributes
I have geodataframe of many LineStrings. The LineStrings intersect but are not split at those intersections. My current solution to achieve this is from here:
network = gp.read_file(filenameNetwork)
...
2
votes
1answer
43 views
Create a raster from polygon
I have a shapefile of thousands of polygons.
I'm looking to loop through each polygon and create a raster of the shapefiles boundaries for each polygon.
I'm looking for each raster to have the value ...
1
vote
1answer
21 views
Compute area coverage density estimate from very large polygon dataset
I am trying to come up with a pipeline for turning very large OSM PBF files (eg buildings layer for a whole country: ~100M polygons) into a more manageable density estimate (with arbitrary precision).
...
0
votes
1answer
15 views
Drop Linestring geometry from a GeoDataFrame
I try to create a shapefile of the FAO/GAUL/2015/leve1 country regions of the LMIC's countries.
For that I decided to use Python as it gave me access to the earthengine API and the geopandas librairy.
...
2
votes
1answer
80 views
Fast way to extract bounding boxes from OSM PBF data…
Is there an efficient way to convert a set of node/relations in a PBF file, to the bounding boxes for each polygon, without going through a conversion to another GIS format?
Right now, my pipeline ...
1
vote
1answer
467 views
Error while using sjoin in GeoPandas
I have a problem with GeoPandas sjoin, I work with Ubuntu and I want to use:
opolskieadresy = geopandas.sjoin(smallopolskie, adresy, how="inner", op='intersects')
and i'm getting error:
...
0
votes
1answer
79 views
How to create a GeoPandas GeoDataFrame from rasterio features?
I try to create a GeoDataFrame of paches of same values in a binary raster using rasterio and GeoPandas. data_file is a binary TIFF raster with 0 where there is no deforestation and 1 if there is a ...
1
vote
0answers
60 views
Getting the center point of a cluster in Pandas
I have a list of of coordinates that have areas mapped out as follows
import pandas as pd
import numpy as np
import folium
from folium import plugins
from folium.plugins import HeatMap
import pyodbc
...
0
votes
0answers
118 views
Removing duplicate points in GeoPandas using distance and time
I have a list of of coordinates that have areas mapped out on a map
user_id id latitude longitude requested_at
84 106 13.0472367 77.5022635 12-10-2020 14:59
84 107 13.0472789 77.5024498 ...
3
votes
2answers
163 views
“Multi-part geometries do not provide a coordinate sequence” error when extracting the long and lat of start and end points in GeoPandas
I am trying to extract the start and endpoint coordinates in GeoPandas. Following this link, I am using this code to extract the start and endpoints for GeoJSON files.
def add_start_end_nodes_to_gdf(...
0
votes
1answer
78 views
Contextily add_basemap uses wrong extent and zoom level
I'm trying to add a contextily basemap to a Matplotlib figure containing a GeoPandas data frame. When I just plot the data frame using df.plot the map extent is calculated correctly.
However, when I ...
1
vote
1answer
74 views
Find points in the same direction
Given a vector of two points with direction from point 1 to point 2:
latitude_1 longitud_1 latitude_2 longitud_2
41.378118 2.169557 41.389474 2.156421
Find points in the dataset that are in ...
2
votes
1answer
51 views
GeoPandas won't read PostGIS Polygon Table
I want to read my data on postgis using geopandas but it won't read. It works on Linestring data, but not on Polygon. When I open the postgis data using QGIS and it works fine, the polygon reads good. ...
3
votes
2answers
224 views
Quick way to get WKT from a GeoDataFrame's geometries in GeoPandas?
Is there a quick way to produce a column/series containing the WKTs of all the geometries in a GeoPandas GeoDataFrame?
I got around this using the apply function (see example below), but I just ...
4
votes
1answer
192 views
Reading non-standard JSON / TopoJSON files in GeoPandas
I am unable to read a TopoJSON / JSON file in GeoPandas. The issue is that it's a JSON file with keys that are "probably" not standard.
I tried to use the from_features() method but it gives ...
1
vote
1answer
173 views
Mapping multiple polygons on Folium
I have a list of of coordinates that have areas mapped out on a map
Zone zone_name users distinct_users geometry
1 A 635 51 POLYGON ((13.05584728590942 77....
1
vote
1answer
362 views
How to change the font size of the color bar of a GeoPandas choropleth plot
When I try to use the legend_kwds argument to change the font size of my colorbar, I keep getting this error:
TypeError: init() got an unexpected keyword argument 'fontsize'
ax = df.plot(figsize=(20,...
1
vote
2answers
84 views
Converting a column with coordinates in Pandas to GeoPandas
I have a list of of coordinates that have areas mapped out on a map
zones coordinates
1 [[13.055847285909415, 77.47638480859382], [13.04673679588868, 77.50519132714851], [13.03294330911764, 77....
0
votes
0answers
65 views
Fixing a corrupted geometry column with Python GeoPandas
I had a shapefile which I converted to a geodataframe, and created a geometry column. I did some manipulation with it in pandas. I am now trying to convert it back into a geodataframe and eventually a ...
0
votes
0answers
37 views
How to delete nodes that are unnecessary
I got a OSMNX graph, and put edges and nodes in two separated GeoDataFrames.
Now I want to delete the nodes that dont intersect with the edges, or nodes that are not very, very close to the edges.
I ...
1
vote
2answers
39 views
Create MultiPolygon from Dataframe column
I have a dataframe with a column called geo_shape, for each row in this column data is in the format str with the following structure:
{"type":"MultiPolygon","coordinates"...
1
vote
0answers
83 views
Unable to get the correct tiles using `bounds2img` via contextily and geopandas for USA
The main idea is to get a png/jpg image file as a basemap for the complete bounds of a geodataframe.
The geodataframe here happens to be a map of the USA which I took from the topojson/us-atlas ...
0
votes
0answers
35 views
GeoPandas plot range problem
I read a .csv file with geometry like this:
trajs = pd.read_csv("trajs.csv")
trajs["geom"] = trajs["geom"].apply(wkt.loads)
trajs = gpd.GeoDataFrame(trajs, geometry="...
0
votes
0answers
37 views
Plotting two shapefiles in same plot. Legend of 1st shapefile hidden by second shapefile. Python GeoPandas
With
ax = gdf.plot(cmap="jet", column=ColumnaAVisualizar, categorical=True,figsize=(12,12),legend=True)
ax2=ZDE.boundary.plot(ls="--",color="k", label="Zona de ...
0
votes
1answer
37 views
Merge overlapping polygons based on attribute
My objective is very similar to these questions: here and here. The only real difference is I want to merge overlapping polygons if they are of the same class (an attribute).
For example, if polygons ...
0
votes
1answer
26 views
Unable to get latitude and longitude of the US map from TopoJSON's us-atlas repository when using GeoPandas
To do some geospatial analysis I am using the USA counties map from topojson/us-atlas repository
After loading the link https://cdn.jsdelivr.net/npm/us-atlas@3/counties-10m.json in geopandas I get the ...
0
votes
2answers
47 views
Python GeoPandas: fill small gaps between Linestrings in a graph to get only one connected component? [closed]
I have a graph in Python GeoPandas with many connected components. And I want to create a graph with only one connected component.
Does there exist some convenience functions to fill the gaps in ...
0
votes
0answers
21 views
How to translate from GeoJSON to GeoDataFrame [duplicate]
I want to convert GeoJSON into a GeoDataFrame, but it doesn't work.
GeoJSON is stored in a dictionary variable.
If you know of a solution, I would like to know how to solve this problem.
This is my ...
0
votes
1answer
112 views
GeoPandas to DXF [closed]
I have ten geodataframe;
I would like to export each one of them to DXF:
geodataframes= [gdf1,gfd2,gdf2]
for geodataframe in geodataframes:
#geodataframe to dxf
it would be possible?
3
votes
0answers
41 views
Finding union of many geodataframes using GeoPandas
I have a series of many GeoPandas Polygon objects, each with an associated exposure time. My goal is to find the union of all the Polygons in order to create an exposure time map.
For each Polygon in ...
0
votes
0answers
18 views
Geopandas Overlay Union Issue
I was trying to develop an equivalency file between two sets of zone systems (polygons). My script reads in two separate shapefiles, reprojects them to the same projection, calculates the total area ...
1
vote
0answers
35 views
GeoPandas Overlay Intersect not intersecting some areas
I have a GeoDataFrame where I want to get all intersection between the polygons comprised in it. The cope i use for this is this:
intersection_list = []
for index in input_gdf.index.to_list():
# ...
0
votes
0answers
46 views
GeoPandas and Cartopy how to dynamically zoom to Multiline
I am new to GeoPandas and Cartopy.
I am trying to generate map plots for different regions dynamically.
When generating the image from geopandas ('df.plot()') the size is correct, but when I generate ...
3
votes
2answers
58 views
GeoPandas distance optimisation
I have created the following function that measures the distance from one point in a GDF to all points in another GDF and returns a table back with the shortest distance for each point. It works well ...
1
vote
2answers
64 views
What coordinate system is this? How can I project it to WGS84 (lat-long) system in Python?
I had an AutoCAD drawing of a floor plan. I imported it to python using Fiona and checked the metadata. The CRS is empty. When I checked the coordinates for the geometry, it was in the following form,
...
0
votes
1answer
54 views
GeoPandas setting geometry for a row with .loc and Multipolygons
Given the following example:
def merge_with_largest(input_gdf,poly):
# select the polygons bordering polygon
close_by_gdf = input_gdf[input_gdf.geometry.intersects(poly)]
# selects ...
1
vote
1answer
80 views
Return empty dataframe when reading KML file of 'Sentinel 1 Acquisition Segments' using GeoPandas
I have downloaded the KML file of 'Sentinel 1 Acquisition Segments' from this url. I have written this code to read KML file into GeoDataFrame, but the code returns empty GeoDataFrame.
>>>...
0
votes
1answer
36 views
Find vertices of LineStrings within Polygon - Shapely
I would like to use Shapely to find the vertices that are located within the boundaries of a Shapely Polygon. So far, I could only manage to get it running by converting the LineString and the Polygon ...
2
votes
1answer
81 views
Converting DataFrame with geometry column into GeoDataFrame in Pandas
I have this DataFrame:
In [120]: a
Out[120]:
a b c
0 111 333 [POINT (0 0)]
1 222 444 [POINT (0 0)]
I am trying to convert with the next line, but it fails:
In [125]: b = ...
1
vote
1answer
111 views
Contextily not showing basemap
I have a geopandas dataframe that contains bus boarding data. I'm trying to display a subset of the data on a plot using a Contextily basemap but the basemap does not appear.
I created the geometry ...
0
votes
0answers
38 views
Self union a geodataframe whilst retaining columns of overlapping features
I have a geodataframe with overlapping polygon features. I want to mutate this to create a non-overlapping polygon geodataframe. I know I can merge the geometries by using unary_union as shown here: ...
0
votes
1answer
98 views
Polygon Produced Using Geopandas Buffer Not Correct Size
I have created 2 plots as pictured:
The blue (with red outline) polygon should be a 10KM circle around the central dark green point in both plots.
This is correct for the right hand side plot (the ...
3
votes
1answer
66 views
Removing one to many links when performing spatial join in GeoPandas
I am spatially joining census data to building data using GeoPandas spatial join gpd.sjoin(left_df=gdf_building,right_df=gdf_census_data, how="left", op="intersects"). In the ...
2
votes
1answer
293 views
Zoom to a plot with GeoPandas based on data from CSV and shapefile
Here is my code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import descartes
import geopandas as gpd
from sklearn.cluster import KMeans
from sklearn.preprocessing import ...
1
vote
1answer
56 views
How do I write out a mixed geometry geodataframe to a geopackage?
I have a geodataframe of several thousand rows, mixed geometry (Point, LineString, Polygon). I would like to write this out to a geopackage with different layers per geometry type. Here's what I've ...
0
votes
0answers
61 views
AttributeError: 'NoneType' object has no attribute 'length' when running function for compactness
I want to calculate compactness indices for geometries I have in a geodataframe.
I'm using the following function as was mentioned here (Measuring compactness in Python) by Kadir in order to ...
1
vote
1answer
669 views
GeoPandas intersects doesn't find any intersection
I want to check if points layer that I have intersect with polygons layer that I have, as Boolean column in the points dataframe.
I have two GeoPandas dataframes, the first one is many points and ...
0
votes
0answers
18 views
Equal Distance projection in GeoPandas
Does GeoPandas offer some dedicated Equal Distance projection like it is available for example in FME during buffering (https://www.safe.com/transformers/geographic-bufferer/) or in ArcGIS when ...
1
vote
0answers
51 views
Differences in calculating area of a shape between QGIS and GeoPandas
I'm trying to understand how to calculate the correct area for a shape. I'm well aware from many of the searches that I need to select the right CRS to be able to calculate the right area, but my ...
-1
votes
1answer
159 views
Converting TIFF file and changing CRS
Is there a fastest way to:
Load a .tif file
Convert it into GeoDataFrame
Change Coordinate Reference System
I am using Python, and what I tried to do is:
Use rasterio to check if the Source CRS is ...