Questions tagged [geopandas]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
60 views

How to display together a shapefile (country basemap) and points (from CSV) via geopandas?

So, I wrote this code that tries to do it but I end up with the map and points being displayed separately import pandas as pd import geopandas as gpd from geopandas import GeoDataFrame from shapely....
3
votes
0answers
47 views

How do I find where a line intersects itself?

I am using Python 3.7 with Shapely and GeoPandas. I have a big line of 181,000 points, and would like to find all the points where the line intersects itself. It does so a lot. I don't need a new ...
0
votes
1answer
68 views

Splitting polygons based on points density [closed]

I have a geojson file with polygons representing administrative regions. I also have a shapefile from which I can extract a list of points of interest (schools). I can iterate over this list of ...
4
votes
2answers
219 views

GeoPandas 0.6.1 installed instead of 0.7.0 in conda windows 10

I have problems using the .clip utility from the GeoPandas package. I found in this post that the problem might be due to the GeoPandas version, since this utility is only available in > 0.7 version. ...
0
votes
0answers
19 views

How to efficiently pass QgsMapLayer to geopandas.read_file()?

I want to do statistics using geopandas/pysal on existing layers - all geopackage loaded in QGIS. Now layer.source() >>>'/path/to/gpkg|layername=layer' uri = sel_bystr(layerStr).source()....
0
votes
0answers
134 views

shapely wkt.loads - skip bad geometries?

I'm trying to convert an excel file into a Geopandas dataframe. I'm trying to use shapely and wkt to do so. After reading the file into pandas, I have a geometry column. I'm trying to do the ...
1
vote
1answer
84 views

Typerror when using Geopandas.to_file

I am trying to save some Shapely Polygons to a .shp so that I can view and map them in QGIS. This data resides in my projects.hull column. I am running into a Typeerror which I am finding difficult to ...
1
vote
0answers
163 views

Geodataframe to PostGIS or shapefile

I have a GeoDatFrame df : df.geometry.name >>>'geometry' df.loc[:, 'geometry'] >>> Identifiant 0 MULTIPOLYGON (((2.827 42.691, 2.828 42.691, 2.... 1 MULTIPOLYGON (((2....
4
votes
1answer
400 views

Convex Hull in GeoPandas

I have a shapefile with a number of points. Using GeoPandas, I am trying to create a convex hull around the set of points. However, my output layer returns the same points as were fed in. My ...
3
votes
1answer
72 views

CSV containing GeoJSON format geometries to DataFrame

I have a CSV file I open as a DataFrame. Among the columns is one named geom 1 : df.loc[:, 'geom 1'] >>> 0 {'type': 'Polygon', 'coordinates': [[[2.826589... 1 {'type': 'Polygon', ...
1
vote
1answer
21 views

How to update attributes of a GeoDataFrame based on another database of the same geometry

How to update the attribute of a GeoDataFrame based on another database? I have a master GeoDataFrame with line features. I have another GeoDataFrame (say obs) which is a subset of the master ...
0
votes
0answers
136 views

Unable to install GeoPandas

Trying to install GeoPandas using Anaconda for Python 2 (geopandas version in anaconda navigator is 0.6.1). I also have ArcGIS 10.7 pre installed. First when I tried to install it through the ...
1
vote
1answer
146 views

How to append the .csv data into GeoJSON using Python

The .CSV file has 6 indents, we need to append all the indent with GeoJSON file and updated file ready for open in QGIS import json import copy import csv import sys #print(sys....
1
vote
1answer
61 views

Export Polygons as Polygons and not MultiPolygons in shapefile

I have a problem when trying to export my Polygons with geopandas in shapefiles as Polygons. When I import the file later on in QGIS, they are analised as MultiPolygons. I believe it is a tendency ...
1
vote
1answer
685 views

GeoPandas installation errors

(base) C:\WINDOWS\system32>conda install -c conda-forge geopandas Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with ...
0
votes
0answers
110 views

Fixing encoding error when exporting GeoPandas dataframe to Esri shapefile

When I try to export a list of geodataframe to esri shapefile like this: out_path = os.path.join(out_folder, filename) df.crs= "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" df....
1
vote
1answer
43 views

Shrinking a bulky GeoJSON

I converted shapefile to GeoJSON, the shapefile is 10mb and the result of GeoJSON was around 30. In order to make this conversion, I used the following code: import geopandas as gpd SHP_FILE = './...
1
vote
1answer
75 views

How to obtain mean, maximum, and mininum of all points located within polygons using spatial joint in python?

I am trying to estimate summary statistics of points located inside a polygon. Each points in the point layer is associated with N attributes. My target is to summarize (say mean, min,..) the ...
2
votes
0answers
40 views

How to do nearest neighbor search more quickly?

I am currently using geopandas and scipy.spatial to do a nearest neighbor query. I have a data set of close to a million points and I need to find all of the closest points from another data set that ...
0
votes
1answer
45 views

How to extract long and lat of start and end points, to seperate columns, from the geometry column in GeoPandas?

I have a line shapefile in GeoPandas. How can I extract the start and end coordinates as (x,y) pairs in two separate columns? import geopandas as gpd gdf = gpd.read_file(pth_line_shapefile) gdf['...
0
votes
0answers
24 views

How to plot pies or histograms around points (GeoPandas) containing different level values indicators?

This is my code (a simple sample of df). I'd like to have around each point on a map, an histogram or pie showing the mechanical bikes out of the total. import pandas as pd pd.DataFrame( {'...
1
vote
2answers
111 views

Extract polygon name dataframe if the geo-point is inside polygon?

I have two dataset one with polygon name and polygon and other with location name and latitude and longitude. Data 1 (Geopandas Dataframe) import geopandas as gpd data_poly = gpd.read_file(path + "...
1
vote
1answer
77 views

How to extract max elevation values for each road links in a shapefile using Python libraries?

I want to extract values from a raster DEM file for each feature (polyline) in a shapefile. For each feature in a road shapefile, I want to extract the max and min elevation within a buffer (say 10 ft)...
0
votes
0answers
12 views

Max text length Fiona\GeoPandas enables

I have a GeoDataFrame that i am trying to save as a JSON however when the length of a value is longer than 253 chars it is being cropped. Does anyone know how to change it?
1
vote
1answer
61 views

Changing CRS using GeoPandas in Python when print(file.crs) gives 'None'

I'm trying to change the .crs from a cylindrical projection (WGS84 (lat/lon)) to a Mercator-projection. Some information can be found here. However it doesn't seem to work for me for this shapefile ...
1
vote
0answers
75 views

GeoPandas fill polygon gap according to gap area

I have several polygons with holes and I would like to fill the gaps with sizes smaller than a certain area import geopandas as gpd from shapely.geometry import Polygon # Initializing a polygon with ...
1
vote
1answer
25 views

Convert long lat tuple into linestring

I have a dataframe of long/lat tuples and am trying to convert it into a Linestring that I can use in a Geopandas dataframe. The current format is [(-105.279, 40.060), (-105.279, 40.058), (-105.282, ...
0
votes
1answer
81 views

Attempting to get the distance between two Point objects. Getting AttributeError: 'GeoSeries' object has no attribute '_geom'

I am a beginner in GIS. Using the code below to get the distance between two Point objects from two separate GeoDataframe. Using the shapely distance function. Can someone please explain to me what I ...
1
vote
1answer
42 views

Error with conversion from shapefile to GeoJSON

Currently, I am trying to transform a shapefile to GeoJSON, I have the .shp, .shx, .dbf and .prj files. In order to do this I have the following code: import json import geopandas as gpd import ...
0
votes
0answers
8 views

saving and reopening alters coordinates geopandas [duplicate]

I have a Linestring out of which I take the last coordinate tuple and define it as a Point. I save both objects with geopandas as two shapefiles. Later I reopen both objects and I find the Point-...
1
vote
1answer
20 views

Fast way of querying existence of a point between two dataframes

I'd like to check if a point in one dataframe exists in another using Python. I have two shapefiles / GeoPandas dataframes with each over 10000 rows, and the geometry is stored as points (eg. POINT (3....
2
votes
3answers
322 views

Mask xarray dataset using a shapefile [closed]

I have an xarray dataset of some satellite data and I'd like to mask it using a shapefile. I have previously been doing this using a combination of PIL, numpy and gdal but it would be cleaner to do ...
2
votes
2answers
120 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
62 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
41 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
304 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
67 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
50 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
29 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
103 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
55 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
44 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
48 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
159 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
85 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
96 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
76 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 ...
1
vote
0answers
758 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
109 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 ...

1 2
3
4 5
14