Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
35 views

Dump multiple geometry columns of a GeoDataFrame to Features in a FeatureCollection (GeoJSON) instead of properties?

I have a GeoDataFrame with some of its attributes that are geometries (only the position is the one which was interpreted as the active geometry when loading the data from PostGIS): import psycopg2 ...
1
vote
1answer
39 views

Looking for empty polygon

I have a shp and I would like the exploded view with geopandas in several polygons,I cannot use ARCGIS and keep that the polygons which have a given. import csv import glob import pandas as pd import ...
2
votes
1answer
23 views

Cannot write int value into a Geopandas GeoDataFrame

description of the problem I'm writting a function to simplify my use of rasterstat. def zonal_stat(src_rst, mask_vector, out_vector, measurments=available_stats[:4], verbose=False): ""&...
1
vote
0answers
41 views

Passing dynamic query parameters to an SQL query string in GeoPandas read_postgis() method

Up to now, I used to query geospatial tables with psycopg2 and then convert the geometries to my needs using, e.g. Shapely. Per the psycopg2 documentation, you never format your query string yourself. ...
2
votes
1answer
20 views

Display GeoPandas on rasterio doesn't work inside loop

I have written a loop that suppose to open raster from file, display it as rgb and then plot on top of it GeoPandas plot. The problem is that the plots do not appear on to of the rasters inside the ...
1
vote
1answer
20 views

Create square grid on raster file

I have tried to create a fishnet(10 by 10) using the below code. But the output is as shown below. What is that I'm missing in the below code? import geopandas as gpd from shapely.geometry import ...
2
votes
0answers
50 views

Function that runs perfectly fine outside of QGIS keeps crashing QGIS (3.16) Python 3.7

I'm very new to QGIS, PyQt and even Python so I'm sorry if there is a very obvious mistake I am making, but I can seem to get one of my functions to run from within a plugin I'm writing for QGIS (3.16)...
0
votes
1answer
25 views

python - psycopg2.errors.RaiseException find_srid() - could not find the corresponding SRID

I'm trying to import a layer into a PostGIS database with gdf.to_postgis('test_polygons', engine, if_exists='append', index=False, dtype={'geom': Geometry(geometry_type='POLYGON', srid= 4326)}) And I'...
1
vote
0answers
36 views

How to make ocean drainage map using Python

I'd like to make ocean drainage map like this: In particular I'm interested in Russia. A relatively explicit data source is hydrosheds.org, however from there i can get data to display only endorheic ...
2
votes
2answers
60 views

Raster to GeoPandas

I have written a little script to raster to GeoPandas dataframe: with rasterio.open("INPUT FILE", 'r') as raster: df = pd.DataFrame() puntos_calados_combinados=[] puntos=[] ...
4
votes
0answers
53 views

Convert the geometry column of a GeoDataFrame with mixed geometry types to a unique multi-type

I have a GeoDataFrame where I have a mix of geometry types in its geometry column, some are multi-geometry types, some are single geometry types, some are empty geometry types, and others are None (...
1
vote
1answer
44 views

Negate the shapely intersection predicate

I have two Shapely geometries: 1 MultiPoint instance named multipoints 1 Polygon instance named polygon I can compute their intersection by: multipoints.intersection(polyon) which results in all ...
5
votes
1answer
132 views

Exploding column in GeoPandas

I have a shp with a column NOM_CONCAT and I can not explode it to have a unique information, Each time, I have the same error message and I can't find solutions. #TypeError: explode() takes 1 ...
3
votes
1answer
27 views

Dissolve spatio temporal data with GeoPandas without missing the temporal part

I am wondering if there's a clever way to use the dissolve() method of GeoPandas with a spatio temporal geodataframe without losing the temporal part. I have a dataset where for different days of the ...
2
votes
1answer
27 views

Using GeoPandas intersections to fit a grid on a geometry

I'm trying to write a function that creates a grid over a vector shapefile using GeoPandas: def grid(src_vector, out_vector, size): # read the vector data in mercator proj gdf = gpd.read_file(...
3
votes
1answer
78 views

Converting DataFrame to GeoDataFrame with Polygon [closed]

I would like to convert my DataFrame to GeoDataFrame, but every post is about points. I need to convert polygons. Coordinates are in df['geometry']. How can I do that? My DataFrame is below: I was ...
1
vote
1answer
52 views

Reconstruct full coordinate reference system stored in a GML file

I have been able to parse a GML file and fetch the polygons I wanted. They can be plotted ok when plotted on their own. I have them stored in a GeoPandas data frame, but I am struggling to set the ...
2
votes
1answer
16 views

Can't Form DataFrame from Parallel Offset Output

I've been developing code to take a .csv with lat-long coords and convert them to LineStrings before creating parallel offsets for them. This has been working so far, but yesterday after clearing my ...
5
votes
2answers
49 views

From uploaded zipped shapefile to Geopandas DataFrame in Django Application

I'm trying to get to a point where I can quickly filter thousands of points in a shapefile. My Django application asks for a zipped shapefile to upload, where the zipped file contains at least the ....
1
vote
1answer
72 views

Convert Polygon to Multipolygon with GeoPandas

I'm trying to create a vectors grid from a single geometry, from PostGIS's table to another PostGIS's table; both tables are in the same DB. The input geometry is MultiPolygon and I've previously ...
5
votes
1answer
53 views

Finding the closest point to a polygon in a shapefile using GeoPandas

I have the following map of statistical regions of Belgium: The blue dots correspond to coordinates for which I have temperature data. Surrounded by the red circle is Brussels. As it can be seen, ...
0
votes
0answers
13 views

How to rotate a Contextily basemap in matplotlib and Jupyter notebook

I asked this question on Stack Overflow because I thought the Jupyter Notebook and matplotlib aspects were better suited for that forum, but I didn't have any luck; it is also a geopandas and ...
4
votes
1answer
83 views

Converting Individual Points Instead of Entire Geometries Causes Different Transformation Results in GeoPandas and PyProj

I am working with geospatial data to be used to make calls to the Foursquare API and conduct cluster analysis on extracted data. To do this, it is helpful if I can project data using both GeoPandas....
1
vote
1answer
24 views

How to use GeoPandas buffer function to get buffer zones in kilometers?

I am having trouble with using GeoDataFrame.buffer function. That is probably because of my lack of understanding crs. Here is the case: I have events dataset (points longs & lats) and locations ...
2
votes
0answers
29 views

Not able to extract values from raster TIFF in EPSG:26912, but can in EPSG:4326?

I have an elevation file (.tif) in EPSG:4326 and point data for wildfire occurrence in the same projection. When I use this projection, I can use the following code to extract the elevation value, for ...
3
votes
1answer
83 views

Matplotlib skip color for assigned interval in map plotted from GeoPandas DataFrame, if attribute don't have value in range of user defined bins

I have a GeoPandas GeoDataFrame which I am plotting against a specific column and the colour of the output/map is same for different assigned bins/intervals. The issue is because, sometimes, there is ...
1
vote
1answer
49 views

Legend colour not matching as assigned in the bins in matplotlib map plotted from GeoPandas DataFrame

I have a GeoPandas GeoDataFrame which I am plotting against a specific column and the colour of the output/map is not matching with the colour assigned to different bins/intervals. It should ideally ...
4
votes
1answer
49 views

Removing NaN value from legend in matplotlib map plotted from GeoPandas DataFrame

I have a GeoPandas GeoDataFrame which I want to plot against a specific column. for day in days_list: df2 = csv_file[["state_id", "state_name", "tmx_corrl"]].loc[...
4
votes
1answer
141 views

Geopandas vs QGIS vs ArcGIS area values

I'm calculating areas of a KML in QGIS, ArcGIS and GeoPandas and all of then are different, my results are this: Geopandas ArcGIS QGIS 29.3498 28.500084 25,651554 The original crs of the KML is ...
0
votes
1answer
25 views

How to specify from which file duplicates should be deleted after appending two datasets

I am using python script and ArcGIS Desktop 10.8.1 to synchronize two datasets. There are many (thousands) of duplicate features that I would like to drop in an output. How can I specify that, in the ...
0
votes
1answer
46 views

GeoPandas dataframe from PostGIS table having date column

I have this PostgreSQL PostGIS database and I want to read this data in GeoPandas. I am able to create the GeoPandas database when I exclude the columns having dates/datetime #Reading data from ...
0
votes
1answer
39 views

GeoPandas/Geoplot losing first row when reprojecting

I'm trying to work with the London Borough borders file (https://data.london.gov.uk/dataset/statistical-gis-boundary-files-london) in geopandas/geoplot. It comes in National Grid Easting/Northing ...
1
vote
1answer
23 views

“init” CRS vs regular CRS in GeoPandas

I have a shapefile which I read in via import geopandas as gpd shapes_df = gpd.read_file(shp_f) print(shapes_df.crs) The output was {'init': 'epsg:3857'} I then reprojected via shapes_df = shapes_df....
2
votes
1answer
40 views

How to draw radius buffer around the points and perform intersection with other locations list in GeoPandas Python? [duplicate]

I have two lists of points (latitudes, longitudes) - locations & events: locations = [[54.156014, 53.017209], [2.74284, 103.68141], [3.133688, 102.688424], [24.499918, 55.388891], [21.488382, 61....
1
vote
0answers
32 views

Geopandas .difference between two different shapes produces empty difference

I have been puzzled by this, and I feel like it's a geopandas bug. base = gpd.GeoSeries(dist_to_remove).plot(edgecolor='black', color='yellow') gpd.GeoSeries(prec_shape).plot(ax = base, color='red', ...
1
vote
1answer
45 views

Extracting shapes from GeoTIFF using rasterio returns excessive number of polygons

I am using the shapes interface of rasterio to extract polygons from a GeoTIFF image. rasterio returns an excessive number of polygons which is not expected. It is taking a long time to extract a ...
3
votes
0answers
49 views

Plotting the albedo using Python

import glob import numpy as np import pandas import os import rasterio import geopandas as gpd import matplotlib.pyplot as plt def get_image_stats_only(img_array): raw_stats_dictionary = {'mean':...
1
vote
1answer
77 views

Convert ArcGIS Spatially Enabled Dataframe to Geopandas GeoDataFrame

I have some code that works on geopandas GeoDataFrames but due to a client requirement I suddenly have to access my input data via the ArcGIS Python library, which only allows me to access the data as ...
3
votes
2answers
174 views

PyQGIS is working too slow. Can I use GeoPandas?

I have a layer with classification od buildings. I want to add "Area" to my attributes table and I use PyQGIS. For another layer with 50 records it works, but my layer is huge, contains 6....
0
votes
1answer
48 views

geopandas GeoDataFrame.to_postgis is showing AttributeError: 'GeoDataFrame' object has no attribute 'to_postgis'

I have this geopandas geodataframe which I want to write in the postgis/postgreSQL database. I have followed the steps as shown here by the geopandas docs https://geopandas.readthedocs.io/en/latest/...
1
vote
0answers
15 views

Attribute network features (lines) with data from their endpoint

Goal To prioritize water lines in a network based on the building they service Detail I have a shapefile of water lines in a region. The lines are split at their vertices and form a network (more or ...
1
vote
1answer
26 views

How to split a single polyline shapefile into many shapefiles based on unique value using GeoPandas?

I have a single polyline shapefile with multiple features (row). I want to export each row to separate shapefile with using GeoPandas. But I got Geometry error in the code. This is my shapefile: and ...
1
vote
0answers
37 views

geopandas to_postgis: ValueError: geom (geometry(MULTILINESTRING,4326)) not a string

I have a GeoPandas GeoDataFrame with a column named geom having MultiLineString values as such: print(gdf.to_markdown()) # using package 'tabulate' to display a markdown table | | uid | key | ...
2
votes
1answer
45 views

GeoPandas: Problem with encoding

I have the problem with encoding because I need Polish letters and encoding="utf-8" didn't work. import geopandas df = geopandas.read_file(r'/home/gis/adresypolska/PRG_PunktyAdresowe_POLSKA....
3
votes
1answer
78 views

Calculate Azimuth from polygon in GeoPandas

Is there a simple way / ready-to-go function to calculate the azimuth of 2D-polygons in a GeoPandas DataFrame? My goal is to eventually compute azimuth angles of building footprints. Most of the ...
1
vote
1answer
74 views

How to create a raster delineating all drainage basins using pysheds python

I am going through the tutorial of "Pysheds" available in the following website https://www.hatarilabs.com/ih-en/elevation-model-conditioning-and-stream-network-delimitation-with-python-and-...
7
votes
2answers
59 views

Change linestring values with GeoPandas

I'm working on a stormtracking project, and I realized that the longitude sign of some values in my GeoPandas dataframe are wrong; i.e. I need negative longitudes instead of positive ones. When I ...
0
votes
0answers
116 views

Extract one geometry type from GML file in GeoPandas

I try to use GML data from Landesvermessung Brandenburg in GeoPandas. It generally works to load files like this: df = gpd.read_file(r'/vsizip//vsicurl/https://data.geobasis-bb.de/geobasis/daten/...
1
vote
1answer
21 views

Why is WKT shape empty/not plotting in some tools but not in others?

Why is my WKT Shape: import geopandas as gpd import pandas as pd df = pd.DataFrame({'foo':[1], 'geom_wkt_epsg4326':['MULTIPOLYGON(((16.550706663337998 48.56271555889241, 16.551262218893598 48....
1
vote
0answers
24 views

Calculating ratios between two shapefiles

So I have two shapefiles, one is a grid and one is a map of the world's land. I am trying to find the ratio of land in each cell of the 'grid' shapefile to show the land/water ratio but I'm stuck. ...

1
2 3 4 5
17