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.
29
questions
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'...
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():
...
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 ...
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 ...
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 ...
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:/...
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 ...
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 ...
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:...
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, ...
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 ...
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 ...
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 ...
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: ...
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 ...
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'] = ...
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 ...
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['...
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 ...
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 ...
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 ...
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 ...
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')
...
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 ...
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 ...
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....
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 ...
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 ...
-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. ...