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
1
vote
1answer
32 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['...
0
votes
0answers
18 views

ArcGIS API for Python not plotting Spatially Enabled Dataframe

I'm using Python 3.6.8, Pandas 0.25.3, and ArcGIS API for Python 1.6.2. I'm pulling data from an API and viewing it in a pandas dataframe using a Jupyter Notebook. The data has several attributes ...
1
vote
0answers
17 views

Cannot visualize xarray dataframe after converting to NetCDF

I am trying to convert sample.csv dataframe - link no NetCDF here is what I did import xarray as xr import pandas as pd dfcsv=pd.read_csv('sample.csv') dfcsv=dfcsv.set_index(['latitude','longitude','...
2
votes
2answers
75 views

Accelerating the code for random selection of polygons

I have a shapefile with thousands of features (polygons). I need to randomly sample one polygon at every 1 sq. km. area if at least one polygon is available. I wrote the following code which works. ...
1
vote
1answer
167 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 ...
1
vote
1answer
42 views

Load table with GEOMETRY column to Pandas DataFrame

I am trying to load table (from Postgres DB) with GEOMETRY column to Pandas DataFrame using pd.read_sql_table method. I am getting error becuase GEOMETRY type seem to be not supported: C:\Anaconda3\...
2
votes
2answers
73 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'] = ...
0
votes
0answers
15 views

Faster way to truncate the coordinates than pandas.apply?

If have a GeoDataFrame with loaded coordinates. I'm using apply to truncate the coordinates precision - is there a faster way than using apply? gdf.geometry = gdf.geometry.apply( lambda p: sg....
2
votes
0answers
27 views

Create sequential ID column type when loading GeoDataFrame to PostGIS

Is there a way to define GID column as sequential (auto-incremental) when loading GeoDataFrame (created from Shapefile) to PostGIS? I use Geopandas and "to_sql" method: geodataframe.to_sql(tablename, ...
1
vote
2answers
37 views

Loading GeoDataFrame to PostGIS when GEOM column contains MULTILINESTRING and LINESTRING

How can I load GeoDataFrame (populated from shapefile) to PostGIS when GEOM column contains MULTILINESTRING and LINESTRING e.g.: LINESTRING (14.2384666 46.6304714, 14.2386703 46.6304123) ...
2
votes
1answer
50 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:...
0
votes
0answers
33 views

Error converting a DataFrame to a GeoDataFrame

I have a two DataFrames, one with a Point column and the other with a MultiPolygon column. I need to convert both of then into a GeoDataFrame. To do it with the first one I have used this: geometry =...
1
vote
1answer
38 views

Create a point from a lat/long list using GDAL

I have a shapefile with a bunch of wildfire perimeter data, and a dataframe with lat and long columns about the lat and long of fire origin points. The information is not connected except by date, so ...
2
votes
1answer
299 views

Getting elevation for multiple lat long coordinates in Python

I have seen the answer to Elevation info for multiple lat long coordinates and I would like to be able to do this with a python script instead. I cannot use Googles API because I have 8000 points. I ...
1
vote
1answer
60 views

Calculating distance in feet between points in a Pandas Dataframe [closed]

I am pulling my data from an AGOL feature service using the arcgis python api. I pull the data into a spatial dataframe then merge it in various ways in pandas, do various column calculations, move ...
0
votes
0answers
53 views

Nest a dictionary in JSON with Python for GeoJSON properties

Using the Python GeoJSON library I am creating a feature collection of MultiPolygons. I cannot find a way to include properties (attributes) in the features. I have tried: features = df.apply( ...
1
vote
0answers
29 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 ...
0
votes
0answers
112 views

From SQL database to pandas dataframe to numpy array to ESRI Table

End goal: Join data pulled from a SQL database to three different feature classes in a ESRI geodatabase. Efforts: Using PYODBC, I've connected to the database and dumped the data into a Pandas ...
1
vote
1answer
216 views

Cutting a portion of a satellite image based on coordinates in GDAL?

I have a satellite image of 7-channels (Basically I have seven .tif files, one for each band). And I have a .csv file with coordinates of points-of-interest that are in the region shot by the ...
0
votes
0answers
65 views

Checking for geospatial similarity in Python?

Say I have two pandas dataframes in a format similar to this one where each 'Point' represents a person and where they were at. Assume that there are multiple line strings representing different ...
1
vote
1answer
22 views

How to determine column value based on lowest value from other column? [closed]

I have the following dataframe with same value in 'nearest_beacon' column but different distance in 'vms_distance' column. My Dataframe: nearest_beacon vms_distance associated 4548780 0.486456 ...
2
votes
0answers
48 views

Plotting Geopandas Gallery example fails?

I have been having trouble getting the figures from the example provided in Geopandas Gallery examples. When I ran these scripts in Jupyter console: import geopandas import geoplot import matplotlib....
2
votes
1answer
44 views

Retaining last position of vessel position in geodataframe including time series?

I have geodataframe about vessel position which include unique code called 'mmsi' and time series. In the following 'mmsi' column has more than 1 'mmsi' code and time series (* mark). mmsi ...
2
votes
1answer
91 views

Setting up ArcPy virtual environment with Pandas?

Do I need to bounce back and forth between two virtual environments in order to run Pandas and ArcPy in the same script, while ensuring Pandas (or accidental updates to NumPy) doesn't break Arcpy? I'...
2
votes
1answer
68 views

arcpy.da.NumPyArrayToTable() RuntimeError: Unspecified error

Using arcpy for ArcGIS Desktop 10.7.1... In order to append data from a Pandas data frame to an ArcGIS table, I am attempting to create a temporary in-memory table from the Pandas data frame as ...
2
votes
1answer
28 views

Find gaps in spatial database based on attributes and fill those caps with new features with existing attributes

I have a big line shapefile data (over 2 millions features) showing animal movements. Simplified example: ID    Year    st_time     end_time&...
2
votes
1answer
515 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 ...
2
votes
1answer
450 views

Iterating over column from CSV using pandas? [closed]

The problem that I am experiencing is as following: I have a csv with the following columns: 'time' (with date and time), 'id', 'lat', and 'long'. The data shows movements and id represents a mobile ...
0
votes
1answer
132 views

Returning raw address from pandas column using Geopy?

I have a Pandas dataframe, and I'm calling a geopy function on each row of 'address_original' column to get as much detail as possible about every address from geopy.geocoders import GoogleV3 ...
2
votes
2answers
54 views

Opening different XLS spreadsheets as table with ArcPy?

I am trying to write a Python script that uses a xls file with different spreadsheets as input to build features and domains in a geodatabase. This is the data in Sheet1: and this the data in ...
1
vote
1answer
475 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 ...
0
votes
1answer
111 views

Generating Queried CSV from shapefile using ArcGIS API for Python?

I'm trying to create a csv from a query of a feature layer hosted in ArcGIS Online. The csv only needs to contain one field, where the query is met, geometry is not needed. I'm having issues getting ...
1
vote
1answer
137 views

Extracting values from array created with FeatureClassToNumPyArray and converted to DataFrame?

I cannot understand how to use the values in the arrays created with arcpy.FeaturesToNumPyArray. I want to create an array and then convert them to a pandas DataFrame. So I created an array from ...
0
votes
1answer
526 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
373 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 ...
1
vote
0answers
40 views

Preserving data types when publishing to ArcGIS Online using ArcGIS Python API?

I have a Python script which does some data manipulation using Pandas dataframes, then outputs to CSV. The CSVs are then published to AGOL using the ArcGIS Python API, overwriting the existing ...
7
votes
2answers
3k 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
45 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
1answer
655 views

Creating LineString and length of LineString from multiple latlon points for each row in a Pandas Dataframe

So I want to create a LineString and get the length of the LineString from two sets of LatLon coordinates (points) in each row in a Pandas Dataframe, and store in a new column How can I do this?
1
vote
2answers
311 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 ...
3
votes
1answer
735 views

Creating shapefile 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': '...
1
vote
1answer
81 views

Encoding in Python toolbox?

My Python toolbox uses a function (code below) to save values to a CSV file. When I was using the same code in a Jupyter notebook, saved records were properly encoded (I am dealing with Polish letters ...
1
vote
0answers
432 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
0answers
49 views

Select different columns from each feature layer to be count values [closed]

How to count values (occurences of values) in each feature layer using a loop? The problem is that the column names are not the same for all layers. I have a table that has columns: ...
3
votes
0answers
166 views

QGIS plugin external libraries in plugin’s directory

I’m developing my first QGIS plugin and I have to use two external libraries not included in the default OSGeoW64 installation: Couchdb and Pandas. I would like to include those libraries in my ...
1
vote
1answer
57 views

Joining attributes after selecting one polygon which intersects another using geopandas?

To select the polygons which overlap other layer's polygons, I came up with this code based on what I found on this site: import geopandas as gpd import fiona import os import sys # Get the current ...
1
vote
1answer
6k views

Uninstalling and Reinstalling Anaconda

I had 2 versions of pandas (22 and 23) in my Anaconda environment for Python 3.6. One of the pandas looks like it was installed through Python 2.7 pip. Basically, I am unable to import pandas at all ...
4
votes
1answer
290 views

How to process 2 GeoDataFrames by rows pairwise?

I have 2 GeoDataFrames 100 records each, and want to calculate distances between respective geometries (Points, of course). I can't see how to make it other than write a cycle to iterate rows ...
0
votes
1answer
108 views

StopIteration: iteration not started Error when zipping a cursor using arcpy.da.UpdateCursor

I've run into a StopIteration: iteration not started error while trying to order a table using an update cursor. Is this caused by zipping the cursor together? I've tried updating a different table ...
2
votes
1answer
629 views

Join Pandas Dataframe to Shapefile?

I have a shapefile: Street1 Street2 Street3 Field Clark Taylor Field Jackson State Franklin 23rd 25th And a Dataframe df: Page Entry_Date 12 08012018 17 ...