Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [geopandas]

GeoPandas is an open source project to make working with geospatial data in python easier.

3
votes
0answers
14 views

Python GeoPandas: How do I make a Shapely box larger

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 ...
1
vote
1answer
23 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 ...
2
votes
1answer
23 views

geopandas.intersects() over each row

In trying to answer this question I ran into problems with geopandas.GeoSeries intersects methods. I have the following line and polygon: import pandas as pd import geopandas import pickle line = ...
0
votes
2answers
24 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([...
0
votes
2answers
40 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
1answer
25 views

Equivalent method for .withcolumn() for geodataframe

I am trying to use a user-defined function in pyspark in order to check whether the points in CANmep_GDF lie within the polygons in gda_GDF. from geopandas import GeoDataFrame def check_exist(geom):...
0
votes
0answers
49 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
27 views

Geopandas doesn't fix invalid geometries

I am trying to fix self-intersecting polygons on shapefiles in Python 3 using Geopandas as below: import geopandas as gpd shp = gpd.read_file('shapefile.shp') print(shp.is_valid) 0 True 1 ...
0
votes
0answers
30 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 ...
0
votes
0answers
41 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
1answer
50 views

Python geopandas dataframe of polygons — determine nearest neighbor polygon?

I am trying to figure out how to dynamically create expanded regions of interest based on polygon geometries in geopandas until some threshold is satisfied (essentially custom regions across the ...
1
vote
1answer
57 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
16 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
33 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 ...
0
votes
1answer
45 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
33 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
33 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() ...
1
vote
0answers
59 views

Error in reproject vector file using GeoPandas

I have a vector file (in this case shp file) and I read it with GeoPandas (gpd). vector_folder = r'C:\poly' vector_file = 'poly.shp' df = gpd.read_file(os.path.join(vector_folder,vector_file)) df ...
0
votes
1answer
49 views

Spatial overlays : Union between multiline and multipolygon with geopandas

I try to overlays (apply union) my multipolygon on the multiline with GeoPandas, but it seem like the GeoPandas overlay function work only with (Multi)polygon. Is there any way to make that with ...
1
vote
0answers
66 views

Calculating distance between point and MultiPolygon Geoseries object in Python [closed]

I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code: import numpy as np import pandas as pd ...
0
votes
0answers
23 views

Would like to randomly sample points from within a polygon using Python [duplicate]

I would like to achieve something similar to the ArcGIS Create Random Points tool using geopandas, shapely, or rasterio. I aim to have a polygon with some holes in it (removed by subtracting buffered ...
2
votes
1answer
37 views

Calculating areas of polygons inside other polygons with GeoPandas

I have 2 geodataframes: GDF1 is an area with overlapping polygons divided into 3 classes: (cleaning, infra and maintenance) (the black lines donates the overlapping polygons) GDF2 consists of ...
2
votes
1answer
34 views

Write a Spatial Join output to a CSV?

I am trying this example with different input files. My aim is to merge the country and point tables into one table using sjoin from geopandas and write to a CSV file. I took a look at 1. When I run ...
0
votes
0answers
42 views

Issue with GeoPandas method 'contains' for two GeoDataFrames

I want to verify that a GeoDataFrame called mask2 COMPLETELY CONTAINS all the linestrings in another GeoDataFrame called transect_file2. In the image is clearly visible that transect number 16 (TR_ID=...
0
votes
1answer
30 views

GeoPandas Overlay Symmetric Difference: How to get the upper polygon

I have the following code which get the difference of a pie wedges. c= gp.overlay(a,b,how='symmetric_difference') How to get the upper polygon?
0
votes
0answers
33 views

Creating a grid of modifiable hexagonal tiles as overlay in geopandas

I have geo-tagged car sharing dataset which I am analyzing using geopandas. For analysis purposes I would like to create my own polygon overlay of hexagonal tiles. I have managed to find a ...
0
votes
0answers
92 views

Visualize big data HTML file created with Folium

I have written a Folium map of a French city with the possibility of visualizing attributes informations on click for each of its polygon which makes a huge file after 2 hours of calculation with the ...
1
vote
0answers
34 views

Most effective way to find spatial relationships in python

I am trying to find the spatial relationship between two polygon geoDFs as follows: Find geoDF1.geom within geoDF2.geom else (not within) Find geoDF1.geom with largest intersection fromgeoDF2.geom ...
1
vote
1answer
51 views

Python - Convert shapefile lat-long value from Degree minutes seconds to Degree decimal

I am processing shapefiles in python using standard library functions like Python “shapefile” library and GeoPandas. I have two shapefiles having the same projected co-ordinate system-> ...
0
votes
1answer
64 views

Getting geohash of LINESTRING in PostGIS?

I have some LINESTRING in PostGIS. LINESTRING(104.011 30.637,104.014 30.638,104.022 30.640,104.026 30.645) LINESTRING(104.022 30.666,104.031 30.659) LINESTRING(104.044 30.655,104.056 30.655) I ...
1
vote
1answer
31 views

Check if point in GIS polygon fails to produce correct output

I've tried many, many many, ways to find out if a point is in a GIS polygon based on many great posts, but I can't get any to work properly. Specifically I created a grid of points covering the ...
0
votes
1answer
77 views

Search plugin of Folium doesn't appear [closed]

I'm trying to reproduce the following jupyter notebook : https://nbviewer.jupyter.org/github/jtbaker/folium/blob/geojsonmarker/examples/plugin-Search.ipynb But once I'm trying to create the map I ...
0
votes
2answers
122 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 ...
1
vote
1answer
33 views

How can I avoid changes to field types in geopandas?

I am using geopandas in the following routine to create the union of 2 (polygon) shapefiles: import geopandas as gpd def union(fn_A, fn_B, output): shpA =gpd.read_file(fn_A) shpB =gpd....
0
votes
1answer
42 views

How to create a shapefile [polygon type] from a Geodataframe, returned from a Oracle Spatial cursor with geometry column type=cx_Oracle.LOB?

I'm trying to create a shapefile [2D polygon type] with a Geodataframe, that result from a SQL made to a Oracle Spatial database. The SQL and the Geodataframe creation runs without errors, but when I ...
0
votes
0answers
55 views

Geopandas to_file() gives an error regarding fiona.drivers(). Is it possible to work around this?

I'm using geopandas to get WKT and coordinates from a database: df = pandas.read_sql(con=conn2, sql=test_query) df['Coordinates'] = df['WKT'].apply(lambda x: wkt.loads(x.read())) gdf = geopandas....
0
votes
0answers
23 views

NHGIS census files get lat/lon from polygon

I've never worked with shapefiles before and I'm having a lot of trouble with something that I think should be pretty simple. So I have the census tract files from NHGIS for 1980 and the structure ...
3
votes
1answer
52 views

GeoPandas equivalent of ST_MakePolygon

What is the GeoPandas equivalent of ST_MakePolygon? I want to convert a MULTIPOLYGON to one single polygon. Currently, using GeoPandas.boundary a MultiLineString is returned. How can this one be ...
0
votes
1answer
83 views

Casting geometry to MULTI using GeoPandas?

Shapefiles can mix simple POLYGONs and MULTIPOLYGONs in the same data source. Spatial databases like PostGIS and SpatiaLite are strict, and will not put a POLYGON in a MULTIPOLYGON geometry column. I'...
0
votes
0answers
77 views

Write feature collection to S3

Is there a way to write a feature collection from Python memory to an S3 bucket (as Esri Shapefile, zipped Shapefile or something else) without writing it first to disk? I tried writing to a ...
1
vote
1answer
56 views

Exception raised when saving Geopandas DataFrame into a file

I am trying to apply the method to_file of a Geopandas DataFrame. My DataFrame contains a column Polygon, a column Point, a string and float columns. Here the output of the describe method: <...
0
votes
1answer
356 views

How to fix 'GeoSeries' object has no attribute '_geom'

I'm working on a python script whose goal is to detect if a point is out of a row of points (gps statement from an agricultural machine). To do this, my idea is to make a buffer around the 10 points ...
3
votes
0answers
103 views

Multiprocessing with geopandas

I am learning how to implement the multiprocessing with spatial data using the module multiprocessing. I am trying to implement a spatial intersection between a polygon file and a grid file. I am ...
0
votes
1answer
126 views

How to create a GeoDataFrame points grid from a numpy.mgrid?

I'm trying to create a GeoDataFrame points grid from a numpy.mgrid. I already have created the numpy.mgrid with coordinates of future points. >>>arr = np.mgrid[-1827342.1753285176:-1827523....
2
votes
1answer
513 views

Open GPKG embedded layers in python

I have a gpkg with multiple tables, and I am trying to load it with geopandas: import geopandas as gpd filename = '~/example.gpkg' gdf = gpd.read_file(filename)' This returns the first table/layer ...
1
vote
1answer
103 views

Creating chloropleth maps in geopands with 'user_defined' bins

As suggested in the geopandas mapping tools documentation, I want to create a chloropleth map using a custom defined bin sizes: world.plot(column='gdp_per_cap', cmap='OrRd', scheme='user_defined') ...
2
votes
1answer
579 views

Getting error while importing GeoPandas in Python console

I have installed GeoPandas and its dependencies using pip install package_name. Here is the pip list output: Package Version attrs 18.2.0 Click 7.0 click-plugins 1....
0
votes
0answers
21 views

Map Town names to its corresponding NUTS code

Is there a way to map the Town to its corresponding NUTS code? I have a file which has IP address and Town too, but I was not able to get the NUTS code from the latitude and longitude information ...
0
votes
0answers
67 views

Splitting aerial photography into images with GPS coordinates

Splitting aerial photography into images with GPS coordinates Given this folder structure of (four) Oblique and (one) Vertical aerial photography of 10 cm resolution: dir/Orientations/footprints.cpg ...
3
votes
1answer
399 views

GeoPandas spatial join and count

I have following two GeoDataFrames. One with the crime count per polygon per year. Polygon Year total_crime shape_area geometry 0 0 2009 1 3.266388e+06 ...