Skip to main content

Questions tagged [pandas]

pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language.

Filter by
Sorted by
Tagged with
70 votes
9 answers
81k views

Finding nearest point in other GeoDataFrame using GeoPandas

I've got two geodataframes: import geopandas as gpd from shapely.geometry import Point gpd1 = gpd.GeoDataFrame([['John',1,Point(1,1)],['Smith',1,Point(2,2)],['Soap',1,Point(0,2)]],columns=['Name','ID'...
RedM's user avatar
  • 1,623
79 votes
3 answers
119k views

Converting Pandas DataFrame to GeoDataFrame

This seems like a simple enough question, but I can't figure out how to convert a Pandas DataFrame to a GeoDataFrame for a spatial join? Here is an example of what my data looks like using df.head(): ...
atkat12's user avatar
  • 1,549
15 votes
1 answer
15k views

GeoPandas to_file() saves GeoDataFrame without coordinate system

I have GeoPandas 0.2.1 py27_0 fiona 1.7.0 np110py27_1 Python 2.7.10 installed in Anaconda 2-4.1.1-Windows-x86 environment. I am able to construct GeoDataFrame by reading input datasets and ...
Alex Tereshenkov's user avatar
5 votes
1 answer
4k views

Installing pandas with Esri's python?

Trying to get pandas to import, but I'm getting what looks like an error caused by a failed dependency of the version of my Esri-provided numpy's compile, based on this stackoverflow posting. Here's ...
Roland's user avatar
  • 1,290
14 votes
3 answers
42k views

Making shapefile from Pandas dataframe?

I´d like to construct a shapefile from a Pandas Data Frame using the lon & lat rows. I have got a csv file and I process it with pandas to make a data frame which is easier to handle Is it ...
kamome's user avatar
  • 757
20 votes
7 answers
21k views

Reading raw data into geopandas

Is it possible to read raw data into a geopandas GeoDataFrame, a la a pandas DataFrame? For example, the following works: import io import pandas as pd import requests data = requests.get("https:/...
Aleksey Bilogur's user avatar
10 votes
3 answers
16k views

Geopandas: Write layer back into GeoDataBase

I use geopandas (which uses fiona) to read a GeoDataBase layer (using driver="OpenFileGDB") into a geodataframe for easy manipulation. read_shp = gpd.read_file(GDB_file, layer=layer_choice) That ...
Jens Hiestermann's user avatar
9 votes
3 answers
8k views

Create pandas DataFrame from raster image - one row per pixel with bands as columns

I have a raster image with 3 bands. I would like to convert this image to a csv file where each row will be one pixel and each column will be one band, so that I can easily see the three values each ...
ReutKeller's user avatar
  • 2,207
8 votes
1 answer
2k views

Creating QgsVectorLayer from Pandas dataframe

I am writing a python script for QGIS. I have a pandas dataframe that I would like to use in order to create a QgsVectorLayer. At the moment I am saving the data frame into a .csv and then I load it:...
spec3's user avatar
  • 223
8 votes
2 answers
1k views

"Copy" Image coordinates to another image that is nd.array

I have image with three bands. I have script predicts the first band pixels values by using the two other bands and in the end generates an image.The generated image is at the beginning pandas table, ...
ReutKeller's user avatar
  • 2,207
8 votes
4 answers
24k views

Adding elevation, name and description in GeoJSON when converting DataFrame with Python

I have this working code, data2kml() function works ok, but data2geojson() is incomplete. How can I add the elevation, name and the description in the GeoJSON? I can't understand how FeatureCollection ...
jrovegno's user avatar
  • 293
4 votes
1 answer
12k views

Assign a point to polygon using pandas and shapely

I have a series of Easting and Northing coordinates in pandas dataframe along with other columns of information. I know the coordinates fall within and administrative area and want to match the ...
mapping dom's user avatar
  • 1,512
3 votes
4 answers
30k views

ImportError: No module named pandas in Python window of ArcMap after installing with pip?

I have downloaded pandas from this site then unzipped it in site-packages and run python setup.py for installing pandas. Pandas was installed successfully. After that I tried importing pandas into ...
Gurminder Bharani's user avatar
0 votes
2 answers
128 views

How to round or limit the number of decimals in geodataframe

I need to limit or round decimals in my GeoDataFrame so that when importing to a shapefile and opening a file in QGIS, the number of decimals remains the same as in the dataframe. In GDF looks like: ...
Ilya's user avatar
  • 13
13 votes
1 answer
23k views

TypeError: Input geometry column must contain valid geometry objects

I'm working in a urban biodiversity project and I have a csv file for a birds inventory with a column index called 'geom' composed by multypolygons as this: name geom ...
Rodrigo Vargas's user avatar
8 votes
2 answers
14k views

Building GeoDataFrame row by row

I am trying to build GeoDataFrame row by row, from an empty one. The equivalent using only pandas would be something like this : df = pandas.DataFrame(columns=['a','b','c','d']) df.loc['y'] = ...
Arkeen's user avatar
  • 363
7 votes
1 answer
1k views

Creating polyline from list of QgsPoints using PyQGIS

So I have a CSV of points that I've cleaned up using pandas, and appended to a list with each item being Type: QgsPoint, with its correct X and Y coordinate. I'm trying to find the correct operation ...
Barnard87's user avatar
  • 151
6 votes
2 answers
7k views

Finding distance of consecutive points in a GeoPandas data frame

I am trying to find the distance between every consecutive points in a GeoPandas dataframe. Let's say we have the following data frame: import pandas as pd import geopandas data=pd.DataFrame() data['...
Faraz's user avatar
  • 136
4 votes
1 answer
6k views

Iterate over ImageCollection returning pandas dataframe using earth engine & python

I'm trying to extract values from an ImageCollection to a series of points. My goal is to create a pandas dataframe that includes the values from each image & band of the ImageCollection for each ...
Rob Marty's user avatar
  • 369
3 votes
1 answer
2k views

arcpy.NumPyArrayToFeatureClass exception: "TypeError: narray.fields require"

I have a database application that I connect to using SQLAlchemy. In the database, I store coordinates in the fields x_coord and y_coord, with a third field spatial_reference_code that stores the EPSG ...
nicksan's user avatar
  • 1,716
2 votes
1 answer
1k views

Calculate mean values for all bands and date to a dataframe

I have 5 rasters, each having 10 bands, where each band corresponds to a specific date. How do I calculate mean values for all 10 bands and save them? I need to save the mean values in a dataframe ...
Majda El yacouby's user avatar
2 votes
1 answer
7k views

TypeError: cannot unpack non-iterable NoneType object on Spatial Join

I'm working with two spatial dataframes and am trying to do a spatial join on the two. parcels_sdf -- a frame with around ~370,000 real estate parcels. subdivisions_sdf -- a frame with all ...
leeprevost's user avatar
2 votes
2 answers
1k views

NumPyArrayToTable - RuntimeError: unsupported time units. use M8[us]

I'm trying to convert a pandas dataframe (df) to a table in a file geodatabase using code below: records = df.to_records(index=False) arcpy.da.NumPyArrayToTable(records,r'C:\TEST.gdb\records') ...
Bera's user avatar
  • 76.3k
1 vote
1 answer
2k views

Dissolve feature in geopandas based on multiple attributes

It is possible to dissolve features in GeoPandas based on the attribute field. However, I would like to know how to dissolve features in GeoPandas using at least two attribute fields. Is it possible ...
user8160648's user avatar
1 vote
2 answers
1k views

Preserving coordinates when converting TIFF image to numpy ndarray

I have satellite image that I want to convert into numpy array (and then to Pandas). I already know how to do that, but the problem is that it does not preserve the coordinate data. This is how I do ...
ReutKeller's user avatar
  • 2,207
1 vote
2 answers
3k views

Converting a column with coordinates in Pandas to GeoPandas

I have a list of of coordinates that have areas mapped out on a map zones coordinates 1 [[13.055847285909415, 77.47638480859382], [13.04673679588868, 77.50519132714851], [13.03294330911764, 77....
Ani's user avatar
  • 125
1 vote
0 answers
117 views

Convert ODK geo_shape to geojson

I've collected polygon data using ODK's geo_shape. I'm trying to convert it to a geojson for use in QGIS. I'm using python 3, pandas and geojson to do this. The geo_shape output from ODK looks like ...
Oliver Burdekin's user avatar
1 vote
1 answer
3k views

Parallel processing in Pandas

Using this implementation of parallelization raises an ImportError: cannot import name 'Parallel' from 'multiprocessing' The following code tries parallelization with the "denominator" function and ...
DrSnuggles's user avatar
-2 votes
1 answer
2k views

Getting the intersection of two raster files using Pandas Python

I am trying to get the intersection (the overlap part) of two rasters but the thing is that by comparing them in a dataframe, I cannot find common points. I check on QGIS and there are common areas. ...
TheGame's user avatar
  • 47