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.

0
votes
1answer
26 views

How to create a GeoDataFrame from Dataframe correctly? [on hold]

I am new to Python and struggling with this problem: I have a DataFrame which contains one column called 'WKT' with polygons. I wanted to import it by using gdp.read_file. The import is working but ...
0
votes
0answers
10 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
16 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
46 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 ...
1
vote
1answer
31 views

Casting geometry to MULTI using GeoPandas?

Shapefiles are very sloppy about mixing 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 ...
0
votes
0answers
53 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
22 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
59 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
54 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
62 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
204 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
48 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
478 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
20 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
50 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
125 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 ...
0
votes
1answer
33 views

Geopandas tick labels from a diferent coordinate system

I have a GeoDataFrame that includes points with the relevant geometries (coordinates system WGS84 EPSG:4326) gdf: Name x y Coordinates E -4.375 51.5 POINT (-4.375000000000008 51....
0
votes
0answers
55 views

GeoPandas ParseException: Invalid HEX char error

I am trying to read a geospatial table from a PostGIS database on PostgreSQL. Using the funcion sql = '''SELECT ST_AsText(geom) AS geom FROM my_table;''' df = gpd.GeoDataFrame.from_postgis(sql, ...
0
votes
0answers
120 views

Geopandas KeyError: “['__idx1' '__idx2'] not found in axis” during overlay operation

I'm trying to get the intersection area between two geodataframes using the overlay method. gpd_df1 = gpd.read_file("shapefile1.shp") ## US census tract shape file gpd_df1 = process(gpd_df1) ## ...
1
vote
0answers
90 views

Why is Union in ArcMap much faster than other approaches? [closed]

Taking the union* of these two large shapefiles file1 file2 locally using ArcMap takes appr. 10 min. Over the last few weeks, I've tried to obtain the same results using other, open-source ...
0
votes
1answer
116 views

Create Shapely linestring from string of coordinates in text format

I have a DataFrame where one column consists of lines stored like so: '[[-7.61, 42.15],[-6.62, 43.16],[-8.9, 41.0],[-9.2, 40.5]]' Is there an easy way to read these lines directly into shapely ...
2
votes
0answers
142 views

Overlay Union Geopandas improve performance

How to speed up the "union" of two shapefiles using geopandas? I have two large shapefiles: geodataframe_left.shape = (3610, 12) (500 MB) (link) geodataframe_right.shape = (16396, 3) (200 MB) (link)...
0
votes
0answers
44 views

How to delete little geometries without hole in python script

I'm writing a python standalone script from a old PyQGIS script. Input data is a raster of which I would like to delete little areas. In the PyQGIS script, I vectorized it and used GRASS v.clean to ...
1
vote
0answers
58 views

Basic Python plotting [closed]

Sorry if I sound like I don't understand, but I've been reading around trying to figure out how to do geospatial plotting in Python. I keep running into errors despite the examples I've seen appearing ...
1
vote
1answer
84 views

Compute Moran's I on more than one attribute

I am trying to compute global Moran's I to check for spatial autocorrelation among areas of a city. I am using python, in particular geopandas and pysal. My geodataframe looks like: District_name|...
0
votes
1answer
41 views

Compare same values and keep biggest number's value in another column? [closed]

Here is an example to explain what I mean: I want from this: index area key 0 1 50 1f 1 2 60 2 2 3 70 3d 3 5 80 4 4 1 90 5 5 2 100 6 6 ...
1
vote
0answers
69 views

How to identify unique attributes in a column and add them as separate columns and perform spatial join sum in python

I need to extract all unique values from the "CATEGORIES" column from shapefile 2 (from the Shapefile and its data frame is shown below) and add them as columns to the Shapefile-A data table (see ...
0
votes
1answer
83 views

Using GeoPandas, Shapely and Fiona to “select” state from shapefile, save it and display it? [closed]

I have the usual US census states shapefile for the 48 contiguous states. I am trying to select a state of interest from that shapefile then save that shapefile and display. I want to use GeoPandas, ...
1
vote
1answer
66 views

Reprojection of satellite images mosaic to CRS with latitude and longitudes

I downloaded MODIS product MOD13A1 for India. Then mosaiced the granules in GeoTIFF format using rasterio Python library. I have the appropriate shapefile to mask the mosaiced raster. After mosaicing ...
3
votes
1answer
158 views

How to create the prj file with fiona and geopandas?

I am trying to create a shapefile and a geojson using geopandas and fiona. import fiona import fiona.crs ... geometry = [Point(xy) for xy in zip(df['longitude'],df['latitude'])] crs = {'init': '...
2
votes
0answers
91 views

How to get fast writing with Geopandas & Fiona?

I have a GeoDataFrame with 1,2M records, and want to write it into a GeoPackage file. Currently, it takes >20 minutes, and, as I calculated, average write speed is 100 recs/sec. As I read in the ...
2
votes
1answer
186 views

Extracting Longitude and Latitude from shapefile?

I am working with a shapefile which can be found here. I am doing some data visualisation and want to see if certain longitude and latitudes are within a certain polygon in the shapefile. This is the ...
1
vote
0answers
109 views

Reading data to geopandas using WFS - GML format

This relates to the question here: Reading data to geopandas using WFS? Is there a way to to do the same with a service that does not supply the data in GeoJSON format, but in GML-format? The ...
1
vote
1answer
126 views

PostGIS Symmetrical Difference

Related question I have two tables in PostGIS, each with two features(rows) and a rectangular geometry (polygon). I would like to obtain the Symmetrical Difference from those two layers so that the ...
2
votes
1answer
317 views

Polygon to Point in GeoPandas?

I want to convert a shapefile from polygon to point: pfile = pathtofile file = gpd.read_file(pfile) #it is a polygon Searched this site but didn't find anything similar: http://geopandas.org/...
1
vote
0answers
84 views

GeoPandas geocode error when using Nominatim

I am following this lesson about Geocoding. I have entered: # Import necessary modules import pandas as pd # Filepath fp = r"addresses.txt" # Read the data data = pd.read_csv(fp, sep=';') data....
0
votes
1answer
92 views

Left join using merge in geopandas

Is there a way to do a "left join" when using the "merge" command on a geopandas df to merge by attribute? The problem I am running into is that I am joining a geopandas df with CA counites to a ...
0
votes
1answer
81 views

What is the unit of measurement of the distance between two points using geopandas distance function?

I have created three buffers using geopandas in python and I have a few points scattered here and there, some of them are inside the buffers.But the problem is the following: When I obtain distance ...
0
votes
1answer
29 views

How do I obtain the distances of each point lying inside or outside buffers from the center of buffers?

My aim is to obtain the shortest distance between all the points overlain on a polygon and the center of buffers also overlain on the same polygon. I have done the following to illustrate this: ...
1
vote
1answer
46 views

Adding buffers around each city of user defined region using geopandas?

How do I obtain a buffer around each city on the overlay map of cities on the United States area? I have used the following piece of code to work this out but this does not work out it seems. I am ...
1
vote
0answers
23 views

Python function like SAGA Grid Gridding?

For a python script, I'm searching for a function that does the same as SAGA Grid gridding, an exponential interpolation on GeoPandas GeoDataFrame. Does anyone know one?
0
votes
1answer
137 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....
2
votes
0answers
47 views

Memory errors when doing Zonal Statistics on a multi polygon shapefile in Python

I want to calculate the mean NDVI with the EthNdvi.tif file for each zone (there are around 650 admin zones) in the the woreda shapefile. I'm having some issues with running the following lines of ...
0
votes
1answer
176 views

How to convert GeoSeries polygons to lists of coordinates?

I have a GeoDataFrame consisting polygons. How can I convert each polygon into a list of coordinates? Is there any attribute, method or function in GeoPandas to do this?
0
votes
1answer
122 views

Getting bounding box from Point type GeoDataFrame to getting data from Osmnx

I've a point geodataframe which has only point features inside of it. fishnet_Id ... geometry 0 0 ... POINT (403486 4540640) 1 ...
2
votes
1answer
184 views

Reading data to geopandas using WFS?

I'm new to GIS. Trying to use Finnish population data on 1km tiles available here: http://www.stat.fi/org/avoindata/paikkatietoaineistot_en.html The WFS service is here: http://geo.stat.fi/geoserver/...
1
vote
1answer
173 views

Superposing two plots with Geopandas, with non fill colours in one of them

I would like to plot a map of the edges of the French departments, and the heat maps at the lower scale of the French IRIS. I read both shapefiles using GeoPandas. And now dep.plot(color="white", ...
0
votes
1answer
110 views

gdal/geopandas data object compatibility in python

Is it possible to convert an ogr datasource into a geopandas GeoDataFrame without writing the datasource first as a physical file and reading it back? I am referring to something like import ogr, ...
0
votes
0answers
94 views

How to convert from EUREF-FIN to WGS84 in geopandas

Trying to convert ETRS-TM35FIN coordinates in the EUREF-FIN projection to WGS84 in geopandas with this: x = 429300 y = 7084490 df = pd.DataFrame([[x,y]],columns=['x','y']) df['Coordinates'] = list(...
0
votes
1answer
68 views

ValueError: Invalid field type <class 'bytes'>?

The ValueError: Invalid field type is caused at the last line of this code: fs.to_file(out,encoding='iso8859_7') Full code: q=gpd.read_file(fname + "\ASTENOT\simplify_centerline.shp",encoding='utf-...