Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
89 views

Trying to export shapefile attributetable to JSON using GeoPandas without the geometry

I am using GeoPandas' read_file function to read a shapefile and to_file function to save to GeoJSON. This is working fast and good. But I need to save only the attribute table without the geometry or ...
0
votes
0answers
155 views

Shapely WKT dumps and loads does not always preserve rounding_precision

Shapely's WKT loads and dumps can be useful for rounding overprecise geometries, as pointed out here (Rounding all coordinates in shapely?) and here (Geopandas [Shapely] spatial difference: ...
3
votes
3answers
121 views

Finding all possible adjacent/closest geometrical points from a given point

So, I have a dataframe like this, import numpy as np import pandas as pd import descartes from shapely.geometry import Point, Polygon import geopandas as gpd import matplotlib.pyplot as plt df = pd....
2
votes
0answers
83 views

Save GeoPandas spatial index to disk

I'd like to save the R-tree spatial index generated by GeoPandas to disk. GeoPandas automatically generates an index for each shape (points in this case) in the dataframe. I'm attempting to create a ...
-1
votes
1answer
49 views

Dissolve feature in geopandas based on multiple attributes

It is possible to dissolve features in GeoPandas based on the attribute field. However, I would like to know how to dissolve features in GeoPandas using at least two attribute fields. Is it possible ...
1
vote
1answer
76 views

Trying to project GeoPandas geodataframe geometry to new CRS is not working as expected

I am working with GeoPandas and a Point GeoDataFrame. I have data points in WGS84 (EPSG=4326) that are located in New Zealand. I am trying to project them to a local UTM, but I cannot get the geometry ...
1
vote
1answer
57 views

Extract the north-west point of a shapely rectangle

I am using Python in a Jupyter notebook. I'have created a geometry with shapely and I need to extract the coordinate of the north-west corner of it. from shapely.geometry import Polygon lng = -180 ...
1
vote
1answer
118 views

Difference between mask and bbox in geopandas read_file

Geopandas read has as options bbox and mask. https://geopandas.org/reference/geopandas.read_file.html What is the difference between those two options?
1
vote
1answer
2k views

Plot a circle with a given radius around points on map using Python

I have created a map using GeoPandas with a few markers that represent some coordinates on the map. I want to do draw a circle around each marker with the marker placed in the center of the circle. ...
3
votes
1answer
411 views

Using shapely interpolate to evenly re-sample points on a linestring geodataframe at specified interval

I have a GeoPandas LineString GeoDataFrame. I am trying to evenly interpolate the spacing of the nodes that make up each line, with a couple constraints: keep endpoints unchanged, and specify maximum ...
1
vote
1answer
86 views

Using pyproj inverse transform with GeoPandas and GroupBy + SortBy constraints

I am using pyproj inverse transform to add azimuth and distance "info" to a grouped and ordered geodataframe. I asked a similar question earlier here, but I didn't realize grouping was a ...
1
vote
2answers
100 views

How can I convert a LineString GeoDataFrame to a Points GeoDataFrame while retaining the vertice order?

I have a LineString GeoDataframe that I am trying to convert into a Points GeoDataframe, but I want to retain the GroupBy and SortBy features inherent in a LineString (i.e., all the vertices that make ...
1
vote
1answer
108 views

How to get the bounds of a GeoJSON file in GeoPandas as a seperate file?

I am trying to generate a polygon which circumscribes all shapes in the given GeoJSON (could be either point, line, or polygon shapes). I figured out how to do this with bounding boxes (.total_bounds)....
0
votes
0answers
59 views

Distance computation for geospatial clustering of lat/lon points

I am working with a pretty large dataset (~500K data points) in Python (GeoPandas) and I would like to perform geospatial clustering on some subsets (~60K points) of the data. My question has to do ...
0
votes
1answer
46 views

Identifying and removing bad lines in a shapefile

I downloaded some shapefiles of Houston from the Open Maps data using this tool. I am plotting the roads and I have a weird thing happening. Most of the lines are correct, but there are clearly ...
0
votes
1answer
231 views

How do I change the display size of a map from a shapefile with matplotlib?

I'm completely new to shapefiles. I was able to use GeoPandas to plot some data over a map of the US I got from census.gov. I'm having getting the map to be at a viewable size. I adjusted the figsize ...
2
votes
1answer
121 views

How do I create centroids inside polygons in Python?

When creating centroids from polygons, ArcMap has an option to placing the centroids inside (within the bounds of) the polygons. I am attempting to create centroids in Python. I have tried: df['...
1
vote
1answer
67 views

Using pyproj inverse transform to get azimuth, row iteration and lambda apply (I'm close to the answer!)

I am using pyproj inverse transform to add azimuth and distance "info" to an ordered geodataframe. I am trying to iterate over all the rows in the geodataframe to add the "info" as ...
2
votes
1answer
52 views

Change GeoPandas column value from PostGIS query

I have some QGIS layers and I am performing some spatial queries with them using GeoPandas. I'm using psycopg2 to make a connection to a local PostgreSQL/PostGIS database. Then I use the read_postgis()...
0
votes
1answer
77 views

Clipping points with complex polygon geometry using GeoPandas

I have a huge point dataset with almost 300.000 points and I want to intersect them with a country geometry that has a complex geometry (multiple islands and borders). What I've done so far is to ...
0
votes
1answer
112 views

Using GeoPandas to find crossing azimuths

I have got a series of UTM coordinates and azimuths like that: Point one: Z23, 603484.00m E,7781714.00m S, Azimuth 222° Point two: Z23, 600593.00m E,7781310.00m S, Azimuth 137° Those azimuths (should) ...
1
vote
1answer
57 views

Error when saving geodataframe to geojson after a spatial join

I am writing a simple python code to perform sjoin on two geodataframe. gdf1 = gpd.read_file(polygon1.geojson) gdf2 = gpd.read_file(polygon2.geojson) gdf = gpd.sjoin(gdf1, gdf2, how="...
1
vote
0answers
32 views

Finding “most frequently intersected area”?

I have a geodataframe that contains geometries of droughted area for several years. To identify consistently droughted areas, I want to find areas that are droughted for the largest number of years. ...
1
vote
1answer
87 views

Rasterize function from GDAL in Python has problem with “GetGeoTransform”

I'm trying to rastrize a shapefile that I have. I read the shape using GeoPandas. I would like to give the new raster values based on the shape column called "class" which has numerical ...
0
votes
0answers
39 views

Find polygon geometry of a place

I am reading in a shapefile of Metro areas in the US and then select the metro area of interest. # Read shape file px_shp = 'data/map/az/cb_2018_us_cbsa_500k.shp' geodata = gpd.read_file(px_shp) ...
0
votes
0answers
63 views

Creating a Origin-Destination flow map with Non-Spatial dataset

I am working on a project where I am trying to learn some geopandas. The dataset that I am using is the LEHD Origin-Destination Employment Statistics that gives you a csv that has a work/home geoid ...
4
votes
1answer
540 views

How buffering works in GeoPandas?

I try to add a buffer on a set of lines via the buffer attribute of geopandas. But by testing on a simple case (see code below) I realize that the size of the buffer is not kept according to the ...
0
votes
0answers
44 views

Shapefile extremely slow to read in Jupyter Notebook

I have a shapefile of Phoenix, AZ of size 172mb which I am loading in to the Jupyter notebook. It's a extremely slow process to read the file in. I am running the notebook on locally and the files are ...
1
vote
1answer
35 views

Keep / append attributes to buffered PolyLines in QGIS

I have a shapefile containing multiple line files with key attributes. I buffered each using cap_style=3 to get the correct buffer, but all of the attributes are lost. I'm either looking for added on ...
4
votes
0answers
817 views

Exporting GeoTIFF raster to GeoPandas dataframe

I'm just starting in the field of GIS (mostly worked with just python before) and got stuck on a problem. I'm looking for a way to polygonize an already masked GeoTIFF raster with population data in a ...
1
vote
1answer
64 views

Can I publish a QGIS processing plug-in written in GeoPandas?

Or do I need to rewrite my script using "pure Python" and PyQGIS? My script is basically a recreation of ArcMap's Tabulate Area tool (vector layers only for now). The goal is to make it ...
1
vote
1answer
116 views

Problem getting correct area for polygon and choosing a CRS

Using GeoPandas and I'd like to calculate the areas for the geometries in my dataframe. I'm also doing other things like finding the area of overlapping regions of geometries from different ...
0
votes
1answer
269 views

Reprojecting unequal number of latitude and longitude: pyproj.exceptions.ProjError: x, y, z, and time must be same size

I have a rectangular matrix of geographic climate data with a 1d row of latitude coordinates (size=834) and a 1d column with longitude coordinates (size=1115). They are both in unit of m (EPSG:32630) ...
0
votes
1answer
205 views

“Spatial join” between raster and shapefille- give raster the shapefile values with python

I have raster which has NDVI values .In addition, I have shapefile(geopandas) on top of this raster but it doesn't fully covers the raster (illustration): the shapefile has column which contain data ...
5
votes
1answer
189 views

Get points within maximum distance from any point in GeoPandas

Given a set of points (with meters coordinates), I am trying to create lines between them. But I don't want to create lines of each pair of points, Iwant to create thoses lines if the distance between ...
4
votes
1answer
166 views

GeoPandas groupby is omitting columns

I am using this answer to calculate some basic statistics of some points that fall within the bounds of a polygon (a vector grid), such that: gridfile = 'grid.shp' pointfile = 'points.shp' point = ...
0
votes
0answers
49 views

Display raster with earthpy shows one color raster without values

I'm new to Earthpy, I am trying to display raster and on top of it I want to display polygon. The problem is that when I display the image it looks like blue rectangle and doesn't have different ...
1
vote
1answer
196 views

GeoPandas statistics of points within a multi polygon (grid) [duplicate]

I usually use numpy for my processing but I'm trying to make the most of the power of GeoPandas for my spatial data. I have some point data (shapefile) and a vector grid (fishnet) as a separate ...
2
votes
1answer
70 views

How to put this in a for-loop? I'm recreating ArcMap's 'Tabulate Area' tool in Python

I have two shapefiles, a province with 39 municipalities and a land cover of the province. Goal: get the sqm of each land cover classification for each municipality. For example, how much open forest, ...
2
votes
1answer
208 views

Create GeoDataFrame polygon geometry from coordinates list of lists

My current dataframe (clean_geoms) contains two columns (field_geom_type, field_coords) that I want to convert to a single geometry (GeoSeries) This is a representative sample of my data: print(...
2
votes
1answer
146 views

Getting only the exterior boundary of a 'donut-shaped' GeoSeries object

GeoSeries.boundary() finds the entire object's perimeter, so I supposed that wouldn't work. I made my GeoSeries donut-like shape using unary_union of smaller GeoSeries objects.
0
votes
0answers
36 views

OSM or Google Tile problem fitting to Geopandas Dataframe

I found this good post on how to get basemap tiles from open sources like OSM, Google, Bing, ESRI using python in geographic lat/long. I'm now trying to add the tiles I successfully got into a ...
1
vote
0answers
114 views

How to extract lat, long coordinates from Geography type column in dataframe using SQLAlchemy?

This is the SQL command that works perfectly. SELECT lonlat, ST_Y(lonlat::geometry) AS latitude, ST_X(lonlat::geometry) AS longitude This is the output of the SQL command. lonlat ...
0
votes
1answer
33 views

Problem with intersection between two Geopandas Dataframes

I have 2 shape files one "country.shp" (containing the tiles geometry covering the whole country) & other "district.shp"(containing one particular district). Now I want to get the tiles ...
0
votes
1answer
301 views

Empty geometry error in GeoPandas dataframe

I want to reproject my ground truth data (land reference map) to UTM. # Load Reference Data (reference map = ground truth data): labeled vector data in a shapefile (crops in Jendouba) LULC_filename = ...
2
votes
1answer
81 views

Invalid geometry objects in Shapely list

I have a creating a list of shapely polygons. While I am trying to create a geodataframe from that list it gives an error: intersec_ls = [poly1, poly2, poly3] cu = cascaded_union(intersec_ls) differ =...
1
vote
0answers
76 views

How to write to geopandas dataframe directly to (Google) Cloud Storage?

I would like to write a geopandas.Dataframe directly to (Google) cloud storage, from the documentation fiona enables this, however I am not sure how to supply the correct **kwargs for the geopandas....
1
vote
1answer
51 views

Aggregating DateTime and GPS latitude/longitude

I have a dataframe with multiple columns including SerialNumber, DateTime, GPS latitude and GPS longitude. Background: Tractors marked with Serial numbers are working(driving) on fields, sending data ...
2
votes
1answer
258 views

Find nearest polygon (from GeoSeries) to point (from GeoSeries)

I have two GeoSeries, consisting of points and polygons. I want to find the polygon in dataframe B that is closest to each point in dataframe A. The polygons are rooftops from https://github.com/...
0
votes
0answers
63 views

Optimising Cross Join PostGIS Query

I have tried performing the query shown below via ogr2ogr and the gpd.GeoDataFrame.from_postgis() method in geopandas. from osgeo import ogr import psycopg2, os import geopandas as gpd import pandas ...

1 2 3
4
5
17