Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
174 views

Erasing line features based on intersecting polygons using GeoPandas?

I have two interesecting geopandas.GeoDataFrame datasets, one containing line features (lines_gdf) and one containing polygons (polygons_gdf): import matplotlib.pyplot as plt import geopandas as gpd ...
1
vote
1answer
95 views

Replacing WKT with WKB in PostGIS query & Shapely

I am extracting a geometry (type geometry(Geometry,4326)) from a PostGIS database. I managed to plot them from a GeoPandas GeoDataFrame using the following code : cursor.execute("SELECT id, ...
1
vote
1answer
47 views

Create a function that will convert CSV to other types of files

I'm writing a function with my schoolmates that will convert various files (like shapefile to CSV, CSV to TopoJSON etc, we focus on geospatial data) - we are trying to learn Python. My part right now ...
3
votes
2answers
501 views

Use pyproj new projection initialization method when setting a CRS in GeoPandas

Issue Using GeoPandas: this: (...) t_srs = 4326 gdf.set_geometry('geom', crs={'init': u'epsg:'+str(t_srs)}, inplace=True) or this: (...) gpd.read_postgis(sql_string, conn, geom_col='geom', crs={'...
1
vote
1answer
125 views

Iterate over GeoPandas rows to translate multipoints by different values

I would like to iterate over each row in a GeoPandas multipoint dataframe to translate each point by different x, y values as such: x = [numpy array of x translations of length of dataframe] ex: [5,...
0
votes
0answers
16 views

Find modified rows in two GeoDataFrames having split features

I have 2 GeoDataFrames having features that are essentially LineString and they are identified with a feature_id column. The first GeoDataFrames consists of the original features, while the second ...
1
vote
2answers
60 views

Geopandas errors when using “.within()” in an if statement

I have three dataframes I am working with and want to do the following logic: if dataframe1 in not within dataframe2 but is within dataframe3 then do something first attempt was: if df1['geometry']....
0
votes
0answers
34 views

zonal_stats results misaligned

I am trying to clip a raster file with a shapefile using zonal_stats. The obtained clipped raster however does not follow the polygon in the shapefile and the clipped raster covers more area than the ...
1
vote
1answer
207 views

GeoPandas gdf.geometry.buffer for spatial join

In that part of the code I'm creating geodataframes (only point features) out of two CSV files. I want to merge all points from the two dataframes within a range of 150m. Therefore I create a buffer ...
2
votes
1answer
75 views

Insert Dataframe data into a map using Geopandas

I posted my question in stackoverflow previously, howeverI think this site is a better place to find some clues (this is my first project with spacial data). I need to insert some coordinates from a ...
0
votes
0answers
55 views

Plot GIS polar data on BlueMarble in Python

This is my first time working with GIS data and I would like to plot ice sheet extent on a world map with backround centered on the pole. The shapefile I'm using can be downloaded here: ftp://sidads....
3
votes
1answer
67 views

Remove polygon overlap based on id in Python

I have a Shapefile consists of multiple polygons, where I want to erase the overlap based on the id. An example to visualize the problem: import geopandas as gpd from shapely.geometry import ...
1
vote
1answer
266 views

Cannot open zip, compressed, file on external drive with GeoPandas or Fiona, it opens on C drive [closed]

I am working with Windows 10 and GeoPandas version '0.4.1' which utilizes Fiona version '1.8.11' I am trying to open a shapefile from a compressed folder (as described here https://geopandas.org/io....
1
vote
0answers
101 views

GeoPandas and CRS: different units [closed]

I am trying to write a function that takes as input two files: A Shapefile of a region of interest, A CSV file containing columns with latitudes and longitudes for the stations of interest. The ...
1
vote
0answers
140 views

Changing CRS of GeoJSON

I'm trying to change the CRS of a dataset loaded from GeoJSON. input: { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features":...
0
votes
1answer
128 views

Showing only the external boundary of a GeoPandas DataFrame

I have a GeoPandas DataFrame I collected from a shapefile. The shapefile is the Mexico City boundary from here import geopandas as gpd gdf = gpd.read_file(fname) gdf.plot() I would like to create a ...
2
votes
0answers
1k views

Error importing GeoPandas

I have a problem trying to import GeoPandas. Since it was impossible to install the package in the normal channels within Anaconda, because of possible incompatibility with other spatial packages, I ...
2
votes
3answers
195 views

Convert list of coordinates to LineString within a dataframe

I have a dataframe where one of the columns contains a list of x and y points and I would like to convert it to a spatial data frame but I am having trouble and not sure what to try next. My data ...
2
votes
1answer
197 views

Pandas to GeoPandas : Polygon Geometry, WKTReadingError

I read a PostGIS table with pandas : df = pd.read_sql_table(con=engine, table_name) The column geom contains the geometry of my entity, it is a polygon geometry. I want to convert the DataFrame to a ...
2
votes
1answer
419 views

Error when converting a pandas DataFrame to a GeoDataFrame

I can't figure out how to convert a pandas DataFrame to a GeoDataFrame. Here is an example of what my data looks like using df.head(): crash_date. crash_time latitude longitude ...
2
votes
1answer
273 views

Geopandas (points) to Numpy Array

I have a geopackage with a point feature. Which contains points along 19 lines. So, the number of points per line is exactly the same. Therefore, I could see it as a matrix in numpy. Moreover, each ...
5
votes
1answer
114 views

Read pixel values of a raster image for given coordinates stored in a CSV file

I was trying to find the pixel values of several pixels whose coordinates are known. I did that in this way: import rasterio lons = [66.979, 69.2979, 67.2979 ] lats = [36.5854, 40.9854, 37.9854] ...
1
vote
1answer
74 views

Saving a shapefile to an output file path in my function(which the user will provide)?

I have a function which takes the coordinate argument from the user and converts it to a shapefile, and finally saves that shapefile to the filepath that the user gives. This is the code... epsg_code ...
1
vote
1answer
102 views

Projecting from Lambert azimuthal equal area (LAEA) projection to WGS84 without distortion

I need to convert a shapefile from Lambert Azimuthal Equal Area projection system (North Pole) to WGS84. When I use QGIS to do this, the lines that cross the anti-meridian cross over (horizontal black ...
1
vote
0answers
97 views

Write GeoPandas df to PostGIS - Linestring Z geometry

I am trying to write a geodataframe with Linestring Z geometry to a PostGIS table. This rise the error: ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'LineString' [SQL: INSERT INTO ...
2
votes
0answers
186 views

Failure to write LineString record to shapefile

I have some coordinates from which I am creating a shapefile. tafo_boundary_coords = [(652316, 742792), (652161, 742920), (651897, 743166), (652210, 743477), (652298, 743448),(652375, 743458), (...
2
votes
1answer
102 views

Finding zipcodes within line using GeoPandas [closed]

I have a shapefile of Houston zip codes and gdb folder of lines (within Houston). The lines are in a gdb folder containing over 125 files. The types of files included in this folder are GDBINDEXES, ...
3
votes
1answer
164 views

Missing columns opening GDB with GeoPandas/Fiona

I am trying to import a GDB file database table and convert it to a (Pandas) dataframe. I have been trying to do so using GeoPandas and Fiona. The problem is however that not all columns are being ...
4
votes
1answer
141 views

What is the area of my shapes?

I created overlapping geometries and I would like to know the area of the intersection. import geopandas as gpd from shapely.geometry import Polygon polys1 = gpd.GeoSeries([Polygon([(0,0), (0,1), (1,...
1
vote
1answer
239 views

Using GeoPandas to convert Linestring UTM data to LatLong

I have a few shapely.linestring objects that are read into geopandas with the call: piped = gpd.read_file("Pipes.dbf") In the geometry column the values are in UTM. I have identified the sector as ...
2
votes
1answer
137 views

Python clipping large shapefile by radius [closed]

I cannot find any real answer so I'd like to ask how to crop shapefile with roads in Python. The goal is to leave roads (nodes) in black circle only, then output that to dataframe in geopandas (...
1
vote
1answer
51 views

Drawing a directed line based on dataframe indexes?

I trying to draw a directed graph based on a geopandas dataframe with the Cartoframe library. The Geopandas dataframe has the following structure: deviceId routeLoad longitude latitude ...
4
votes
1answer
410 views

In to_crs of GeoPandas, init proj4 string works, but new style doesn't

I wanted to unify crs into WGS 84, so based on "Manually specifying the CRS" I tried gdf.to_crs('epsg:4326'), but error occurs. I want to know why the old proj4 style gdf.to_crs({'init':'epsg:4326'}) ...
3
votes
1answer
247 views

Extract polygon names from external points: Extremely slow

I have a text file including geolocation points. I have a shapefile containing polygons and name of polygons. For each point, I have to extract the name of polygon if the polygon contains the point. ...
0
votes
1answer
249 views

Create polygons from points with rectangular buffer in Python [closed]

I want to create rectangular polygons from points. Actually I have a GeoPandas point DataFrame and the distance in X & Y direction to form the polygon. The distances are equal for every point. I ...
4
votes
1answer
455 views

How do I correctly reproject a geodataframe with multiple geometry columns?

In the geopandas documentation it says that A GeoDataFrame may also contain other columns with geometrical (shapely) objects, but only one column can be the active geometry at a time. To change which ...
1
vote
0answers
162 views

Viewing GeoPandas Dataframe in VScode or PyCharm like Pandas Dataframes

I'm not sure if this is a missing feature or something that I couldn't figure out so I wanted to get some help; I started learning geopandas library, now I'm following some tutorials I realized that ...
1
vote
1answer
394 views

Creating a shapefile from a numpy array

I was following this tutorial: http://www.acgeospatial.co.uk/k-means-sentinel-2-python/ on how to generate an unsupervised classification for sentinel-2 images. img_ds = gdal.Open('data/products/...
2
votes
0answers
68 views

Geopandas shows points outside of buffer geometry even though inside

I have some ship trajectories and I want to know which point of the trajectory is inside the port(=buffer) and which points are outside. The following picture shows my Geopandas Dataframe with the ...
0
votes
1answer
41 views

Difference in length of lines computed with GeoPandas or in QGIS [duplicate]

So, first of all, here is a test file: https://we.tl/t-xqo5KyRlqD The column length was added using QGIS (v 3.10 A Coruña), field calculator and adding parameter $length. If the file is opened with ...
1
vote
1answer
195 views

Getting geometry column integer SRID from a GeoPandas geodataframe?

The primary answer to Adding GeoPandas Dataframe to PostGIS table? requires entering the geodataframe geometry column's integer SRID. Getting the CRS attribute using the crs attribute like so import ...
1
vote
1answer
29 views

Aggregate data from source value to mask layer by overlapping area

Let's assume I have a georeferenced data set seed_layer.geojson and a mask layer leech_layer.geojson. test_leech.geojson: { "type": "FeatureCollection", "features": [ { "type": "Feature", "...
3
votes
0answers
277 views

OSError - cannot import geopandas

While trying to import geopandas error occurs: Exception has occurred: OSError Could not find lib geos_c.dll or load any of its variants []. I downloaded GDAL and fiona for Python 3.7 from this ...
1
vote
1answer
346 views

Combine multiple polygons into a single one (with holes)

I have the following GeoDataFrame with multiple polygons which represents a single area (raster_val = 1.0) with holes in the middle (raster_val = NaN): geometry ...
4
votes
1answer
161 views

What is the correct way to assign GeoPandas a CRS from Rasterio?

I'd like to be able to create a new GeoPandas object and inherit the CRS from Rasterio, and save a shapefile. The current projection format is seen as invalid when writing an ESRI driver. From here, ...
2
votes
0answers
166 views

Find spatial and temporal variability from a GeoPandas dataframe of polygons

I have a geopandas dataframe of polygons (all rectangles ~100mx120m) and each of these polygons has an attribute for time and % ice coverage. This is all derived from imagery I collected in the ...
1
vote
1answer
26 views

Specify a fields datatype while creating a new field in geodataframe with expression?

I would like to know how to set the field type of ['denominator'] in a geodataframe manually in this expression to "String": geo_df['denominator'] = df[["basalareap","basalareas","basalaread"]].sum(...
1
vote
2answers
1k views

Given list of points (lat, long), how to find all points within radius of a given point [closed]

It's my first time working with GIS. I really wish I could share some code, but I don't even know how and where to begin. I have a Pandas dataframe with around 10,000 records. Each of them have a ...
2
votes
0answers
47 views

Calling geopackage in a loop, “database is locked” error

I try to loop through a folder containing multiple geodatabases (12). After performing some calculation I try to save the results in a new shapefile located in another folder, but the code generates ...
0
votes
1answer
406 views

Convert GeoDataframe to Raster [closed]

I want to convert a GeoPandas GeoDataframe to raster (.tif). I have multiple attributes in my GeoDataframe and want to create a raster using a single field from the attribute table. The underlying ...

1
3 4
5
6 7
15