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
195 views

Something going wrong trying to transform longitude, latitude to NAD 83 using pyproj

I'd like to convert a latitude longitude pair to NAD 83. I've read NAD 83 is equivalent to epsg:4269 and the shapefile I am working with is a US Census TIGER shapefile, all of which are supposed to ...
1
vote
2answers
41 views

How to create a sub dataframe from a dataframe using specific columns

I have a dataframe that has more fields/columns than I want, so I am trying to create a sub dataframe that only has certain fields/columns. The following throws a TypeError: '(['uniqueid'], ['...
2
votes
1answer
229 views

How aggregate data in a geodataframe by the geometry in a geoseries

I have a geoseries where each row is a (square) polygon. Housing price data is in a geodataframe where the geometry is a polygon of the zip code. I need to aggregate the housing price data by squares ...
0
votes
1answer
173 views

Testing intersection between shapely object and geopandas GeoSeries?

This is a Python question, involving geopandas and the libraries it calls, primarily pandas and shapely. tl;dr: I am trying to run a test using if foo.intersects(bar): and am repeatedly getting one ...
0
votes
1answer
116 views

GeoPandas intersect not working as expected

Using GeoPandas 0.4.0 with Python 3.5, I'm finding that geopandas.intersects does not behave as I expect it to. For example, a buffer around Switzerland does not appear to intersect with neighbouring ...
0
votes
0answers
92 views

Improving speed of GeoPandas dissolve?

I am trying to dissolve grid spaces by category using GeoPandas' dissolve function, but it doesn't finish after hours of running and I want to make sure I'm not doing something wrong and/or there isn'...
4
votes
1answer
16k views

Create a polygon from coordinates in GeoPandas with Python

I was trying to create a simple Polygon from a list of coordinates and export it to multiple formats (including shapefile and GeoJSON) and wanted to automate it using Python. There were some good ...
1
vote
1answer
220 views

Error: Input [<shapely.geometry.point.Point>, <shapely.geometry.point.Point>] is the wrong shape for a LineString

I'm trying to create a linestring out of a dataframe of latitudes and longitudes. geometry = [Point(xy) for xy in zip(linkdf.lon, linkdf.lat)] linkgdf = GeoDataFrame(linkdf, geometry=geometry) ...
0
votes
0answers
331 views

Can't open shapefile with GeoPandas

I downloaded a shapefile from the Brazilian Institute of Geography and Statistics (IBGE). I can open it on QGIS and work with it perfectly there, but I need to work with it using Python. I'm trying ...
14
votes
2answers
7k views

Adding GeoPandas Dataframe to PostGIS table?

I have a simple GeoPandas Dataframe: I would like to upload this GeoDataframe to a PostGIS table. I have a Database setup with the PostGIS extension already but can't seem to add this Dataframe as a ...
2
votes
1answer
281 views

How to merge geoseries to geodataframe based on geometry attribute

I have 5868 points in a geodataframe with some columns/attributes. Between points which have distance less than 10 m, I just want to select only one point as representation in that area. I have done ...
1
vote
0answers
424 views

Geopandas simplify results in gaps between polygons

The goal is to simplify the geometries of a shapefile containing multipolygons. However, when I use Shapely's simplify in geopandas, the result contains gaps between the polygons. I was hoping that ...
3
votes
1answer
440 views

Writing GeoPandas data frame to PostGIS?

Similar question has to this has been asked before Adding GeoPandas Dataframe to PostGIS table? I have followed the example but I am running into an issue I cannot solve. There is some geometry ...
0
votes
0answers
77 views

Loading spatialite tables into GeoPandas GeoDataFrame

Using information from here, I am trying to load a result of a SQL Python selection into a Geopandas geodataframe. I know pyspatialite is not longer maintained, so have tried using the dbapi2 module ...
4
votes
2answers
192 views

Geopandas and QGIS Calulating Different Polygon Area Values?

I am just trying to understand why Geopandas and QGIS might calculate areas differently despite using exactly the same shapefiles and exactly the same projections. Both shapefiles are using EPSG:...
0
votes
1answer
165 views

geopandas: “LineStrings must have at least 2 coordinate tuples” when reading gpx files

I am trying to use geopandas to read in some gpx files (generated from a Garmin vista HCX). For many gpx files, given this code: >>> import geopandas as gpd >>> data = gpd....
3
votes
1answer
101 views

Read N number of rows from shapefile using GeoPandas

Pandas has a parameter nrows for selecting how many rows will be read into the dataframe. Does GeoPandas have a similar parameter? Couldn't find in the documentation.
1
vote
1answer
585 views

Performing sjoin on polygons and lines without intersection using GeoPandas?

I want to join a GeoDataFrame with Polygons (circular, were created from Points with buffer) with a GeoDataFrame that has Linestrings. These polygons and lines do not necessarily intersect nor ...
3
votes
1answer
135 views

Re-project GeoJSON from pixel-space to lat-long in Python

I have created a GeoJSON of linestrings in pixel space using Python. However, I now need to re-project the file to match the same projections and extent of the .tiff file I wish to layer the GeoJSON ...
1
vote
1answer
104 views

GeoPandas does not identify points inside polygon

I am trying to intersect some points with a polygon in GeoPandas. First I create a Point GeoDataFrame from a text file. import geopandas as gp import numpy as np import pandas as pd from shapely....
0
votes
0answers
59 views

Opening geodata in GeoPandas?

I've downloaded some geodata but I'm unable to import it into GeoPandas. This is a sample of the geodata (I've trimmed the JSON object): {'displayFieldName': 'NAME', 'fieldAliases': {}, '...
0
votes
2answers
361 views

How to inverse the orientation of the holes coordinates of a polygon in geopandas

I have a polygon shapefile which I am reading with geopandas. The polygon contains holes. My purpose is to add a random point inside each hole. In order to create the points inside the holes (...
0
votes
0answers
235 views

Geopandas ImportError: DLL load failed (in pyviz tutorial geographic data examples) win7

I'm trying to run the geographic data examples from pyviz tutorial. I'm getting the error list in modules below. My Geopandas module work fine (and the others dependent modules) with 3.5 python ...
0
votes
0answers
198 views

TypeError: object of type 'Polygon' has no len() - When trying to plot from a Dataframe

I need to create a LISA map for my work, and I am having problem when I'm trying to plot using geopandas. My data sources are: map_df # A Dataframe A geopandas series : hh = map_df.loc[(map_df['...
2
votes
2answers
326 views

Rounding coordinates to 5 decimals in GeoPandas?

I have a shapefile, which I converted into geopandas dataframe. I would like to round the coordinates to 5 decimals. Is there a method/function in geopandas that can do this? My shapefile contains ...
3
votes
1answer
124 views

Changing CRS in GeoPandas?

I'm trying to plot a bunch of points on a map of Britain and Ireland, and I've been using GeoPandas for that. I've basically just been following the tutorials to do that, and slicing a world map with ...
1
vote
0answers
438 views

Changing CRS of geometry in geopandas dataframe efficiently?

I have a shapefile which I am converting into a geopandas dataframe. The CRS of this shapefile is epsg:4326 and I want to convert this to epsg:3857. import geopandas as gp file_path = 'zip_poly.shp' ...
0
votes
2answers
137 views

Fiona and Geopandas not applying CRS to shapefile during creation

I'm trying to create a shapefile of points from a coordinate list. But, when I use fiona to create the shapefile Arc Catalog is showing that there is no CRS. I tried to add the CRS with Geopandas and ...
1
vote
1answer
693 views

Perform sjoin in geopandas leads to:'AttributeError: 'GeoSeries' object has no attribute 'columns''

I try to find all the polygons in a dataframe thant intersect an other dataframe (made by buffering my polygons) usign sjoin. First I did the buffers gdf['geom_buf'] = gdf.geom.buffer(100) Then I ...
2
votes
0answers
177 views

Python Geopandas reading shapefile taking too long [closed]

I'm relatively new to Python and GIS. I am attempting to read in a 1.1 GB shapefile using geopandas. I let the code run for an hour and it is still not complete. Is this normal? How can I optimize ...
3
votes
1answer
355 views

geopandas.intersects() over each row

In trying to answer Writing selected features to shapefile using OGR and Python? I ran into problems with geopandas.GeoSeries intersects methods. I have the following line and polygon: import pandas ...
7
votes
1answer
1k views

Remove empty geometries from geodataframe

Since geopandas can't perform overlay/intersection with lines, I found a workaround: import geopandas as gpd import fiona from shapely.geometry import shape, MultiPolygon, LineString, MultiLineString ...
6
votes
1answer
842 views

Iterating features and buffering using GeoPandas?

I have a shapefile with many large polygons and would like to process each polygon individually because spatial operations on the entire dataset are too big for memory. For instance, iterate shapefile,...
2
votes
0answers
239 views

Intersecting shapefile/GeoDataFrame using Geopandas, shapely etc?

I'm currently transferring from ESRI to open source GIS by recreating basic ArcGIS tasks in Python, mainly using Geopandas since I have some experience with Pandas. Now I'm trying to intersect a ...
4
votes
1answer
229 views

Making Shapely box larger using GeoPandas?

I'm creating a box that covers the the area of a GeoPandas GeoDataFrame, so that I can use it as an inverted map to later cover up unwanted spill-over data. import geopandas as gpd import geoplot as ...
0
votes
1answer
2k views

Geopandas - Import CSV: make polygons from X,Y Coordinates based on ID

I'm working on a script, where I want to import a CSV file with coordinates and an ID which should be used to make a polygon shapefile from those. CSV file looks like this (example): ID, X, Y 10,15....
1
vote
1answer
393 views

Multiple shapefiles to one GeoPandas GeoDataFrame

I'm trying to vertically concatenate multiple shapefiles that reside in one directory, into one geodataframe. They all have the same table schema and same CRS. I am trying to use the code from this ...
7
votes
2answers
8k views

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....
2
votes
2answers
588 views

How to extract biggest Polygon from MultiPolygon in GeoPandas?

Given a Shapely MultiPolygon, how can I extract the biggest Polygon? For example, given a MultiPolygon as follows: from shapely.geometry import Polygon, MultiPolygon multipolygon = MultiPolygon([...
1
vote
2answers
1k views

Click event on maps with Folium and information retrieval

I was wondering if there is a way in Folium to get the information on an entity we click on with Folium? I'd like the map to either open a tab with the attribute information or just send back ...
0
votes
0answers
511 views

Smoothing shapefiles using Python

The purple is the original polygon to be smoothed and I would like to smooth the polygons as the red line using Python. I tried simplify but looks like I need a buffer and simplify the buffer. But I ...
0
votes
0answers
61 views

How to preserve the Multiploygons using Python?

I converted my input file with geometry Polygon 25D to an output file with geometry Polygon using the below code. As you can see the below image. Problem is that the holes in the polygon is vanished ...
0
votes
0answers
52 views

Locating observations that lies within a collection of Polygons (Python)

I'm trying to locate the observations that lie within a collection of Polygons but my current implementation takes forever, and I suspect that it is because the 'within' method needs to check all ...
1
vote
1answer
729 views

Renaming columns using geopandas - issues with data table in Arc

What I'm trying to achieve: Read in an existing ESRI polygon shapefile Drop an attribute Dissolve by another attribute Rename columns Reorder columns Write out as new shapefile What works: Drop ...
0
votes
0answers
42 views

How can I group the geodataframe on the basis of the column

I have a geodataframe that has a ununique column(text) and polygon geometry for each row. How can I group the gdf on the basis of the column? gathering and converting polygons to multipolygon I think ...
0
votes
0answers
134 views

Geopandas Mollweide projection

I´ve a .gpkg file in Mollweide projection. When I open it in geopandas, it shows me the correct crs information: df1.crs {'init': 'epsg:54009'} I´d like to re-project it to EPSG 4326, in a way to ...
16
votes
2answers
13k views

Getting polygon areas using geopandas?

Given a geopandas GeoDataFrame containing a series of polygons, I would like to get the area in km sq of each feature in my list. This is a pretty common problem, and the usual suggested solution in ...
0
votes
1answer
398 views

Convert CRS for spatial join for GeoDataFrame

I have the following 2 GeoDataFrame variables in GeoPandas. # shp.csr {'init': 'epsg:2953'} # line.csr {'proj': 'sterea', 'lat_0': 46.5, 'lon_0': -66.5, 'k': 0.999912, 'x_0': 2500000, 'y_0': ...
0
votes
0answers
91 views

Geodataframe not plotting properly in geopandas

I am playing around with the gdf.plot method which is supposed to facilitate plotting geodataframes using geopandas. The reason is that I would like to avoid jumping from QGIS to python while ...
0
votes
0answers
127 views

Different values between original raster and cropped raster with rasterio.mask

I have a large sentinel-2 image and I want to clip it according polygons which are stored in a geojson file. My code is: df = gpd.read_file(os.path.join(geojson_folder,geojson_file)) df.head() ...