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
0
votes
1answer
15 views

How to extract a specific country boundary data from a GeoPandas dataset

I want to extract Singapore country boundaries from 'naturalearth_lowres' dataset from GeoPandas. world_filepath = gpd.datasets.get_path('naturalearth_lowres') world = gpd.read_file(world_filepath) ...
1
vote
0answers
23 views

How to vectorize creating a Shapely Polygon in Pandas

I have a GeoPandas DataFrame with a polygon in each row. I want to add a column with coordinates of a bounding box of each polygon. I can do it this way: def create_bbox(row): xmin, ymin, xmax, ...
1
vote
1answer
15 views

Geopandas TypeError when saving a GeoDataFrame after creating CategoricalDtype

I'm trying to prepare a column classification of a GeoDataFrame before exporting to QGIS. So, I use pandas.cut. However, when I want to save it I get a TypeError: Cannot interpret 'CategoricalDtype(...
1
vote
1answer
28 views

Rasterize doesn't preserves the class attributes original values

I'm using this GDAL based rasterize function in python in order to create raster from shapefile based on numerical class values. I am using: function of GDALMy class attributes are very long numbers : ...
1
vote
2answers
34 views

GeoPandas find all possible adjacent/closest geometrical points from a given point

So, I have a dataframe like this, import numpy as np import pandas as pd import descartes from shapely.geometry import Point, Polygon import geopandas as gpd import matplotlib.pyplot as plt df = pd....
0
votes
0answers
19 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 ...
0
votes
1answer
25 views

How do I change the display size of a map from a shapefile with matplotlib?

I'm completely new to shapefiles. I was able to use GeoPandas to plot some data over a map of the US I got from census.gov. I'm having getting the map to be at a viewable size. I adjusted the figsize ...
1
vote
1answer
64 views

Pandas dataframe to Shapely LineString using GroupBy & SortBy

I have a pandas dataframe that contains information to construct (poly)lines, and I want to use shapely & geopandas tools to make a SHP. In the example below, I have 3 lines differentiated by &...
0
votes
0answers
28 views

Creating a Origin-Destination flow map with Non-Spatial dataset

I am working on a project where I am trying to learn some geopandas. The dataset that I am using is the LEHD Origin-Destination Employment Statistics that gives you a csv that has a work/home geoid ...
1
vote
1answer
26 views

Keep / append attributes to buffered PolyLines in QGIS

I have a shapefile containing multiple line files with key attributes. I buffered each using cap_style=3 to get the correct buffer, but all of the attributes are lost. I'm either looking for added on ...
0
votes
0answers
28 views

Manipulate (group, transpose, etc.) a shapefile's table with PyQGIS/Python and export as CSV?

I'm making a QGIS processing plugin that copies ArcMap's Tabulate Area tool which basically calculates, in my case, how much (in sqm) of each land cover classification are there in each municipality. ...
1
vote
0answers
26 views

Memory allocation problem when running Random forest regression in python

I have image with 4 bands . I want to see if I can predict the first band using the 3 other bands. My problem is that I cannot fit the model because I get the following error message: MemoryError: ...
4
votes
1answer
63 views

GeoPandas groupby is omitting columns

I am using this answer to calculate some basic statistics of some points that fall within the bounds of a polygon (a vector grid), such that: gridfile = 'grid.shp' pointfile = 'points.shp' point = ...
1
vote
0answers
67 views

Why ExcelWriter is not working from pands library in QGIS Python console? [closed]

When I am trying to write excel file using python Pandas library in QGIS(version 3.12 & 3.10), it is through up error saying "ModuleNotFoundError: No module named 'openpyxl'" How to ...
4
votes
2answers
121 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, ...
0
votes
1answer
36 views

Is there a more direct approach to time series correlation in the Google Earth Engine?

I want to know how the time attributes of ee.Image and ee.ImageCollectionobjects exist in Google Earth Engine. I am looking for whether there are operations on time series in GEE, such as resampling, ...
3
votes
1answer
111 views

Calculate new band for satellite image after predict values with RF

I have satellite image which contains 3 different bands. I'm using Python (jupyter notebook) in order to calculate new band by applying random forest regression. My problem is that after I have ...
4
votes
1answer
91 views

Plotting a CSV with coordinates one row at a time via GeoPandas

I have a CSV of all earthquakes in my country for the last 10 years arranged by date and time. My goal is to plot each line chronologically one by one, so that I can compile these maps and produce a "...
0
votes
0answers
30 views

Plotting via GeoPandas but only one point shows. What's wrong with my code? Map and points are in same projection

I've been stuck at this for two weeks and have tried already solutions online. I am using Python 3.8. from shapely.geometry import Point import geopandas as gpd from geopandas import GeoDataFrame ...
1
vote
1answer
21 views

How to combine labelling with limited boundingbox when plotting a geodataframe

I am trying to plot a limited boundingbox of my geodataframe setting up some x and y limits to the ax. Everything works but the labelling. This is my piece of code and current result: fig, ax = plt....
5
votes
2answers
80 views

Create pandas df from raster image- each pixel is a row

I have raster image with 3 bands. I would like to convert this image to csv file wso each row will be pixels and each column will be one band, so I can see easily the three values each pixel got. ...
1
vote
2answers
117 views

Extract polygon name dataframe if the geo-point is inside polygon?

I have two dataset one with polygon name and polygon and other with location name and latitude and longitude. Data 1 (Geopandas Dataframe) import geopandas as gpd data_poly = gpd.read_file(path + "...
1
vote
1answer
42 views

Create a function that will convert CSV to other types of files

I'm writing a function with my schoolmates that will convert various files (like shapefile to CSV, CSV to TopoJSON etc, we focus on geospatial data) - we are trying to learn Python. My part right now ...
2
votes
1answer
57 views

Insert Dataframe data into a map using Geopandas

I posted my question in stackoverflow previously, howeverI think this site is a better place to find some clues (this is my first project with spacial data). I need to insert some coordinates from a ...
-1
votes
1answer
31 views

Remove NoData from Data Frame to plot [closed]

I need to remove No Data from the array. Site Data Mean_NDVI 0 HARV 2017-06-21 0.881326 1 HARV 2017-12-14 0.499184 2 HARV 2017-09-09 0.859584 3 HARV 2017-09-25 0.840061 4 ...
2
votes
1answer
140 views

Pandas to GeoPandas : Polygon Geometry, WKTReadingError

I read a PostGIS table with pandas : df = pd.read_sql_table(con=engine, table_name) The column geom contains the geometry of my entity, it is a polygon geometry. I want to convert the DataFrame to a ...
2
votes
1answer
331 views

Error when converting a pandas DataFrame to a GeoDataFrame

I can't figure out how to convert a pandas DataFrame to a GeoDataFrame. Here is an example of what my data looks like using df.head(): crash_date. crash_time latitude longitude ...
5
votes
1answer
101 views

Read pixel values of a raster image for given coordinates stored in a CSV file

I was trying to find the pixel values of several pixels whose coordinates are known. I did that in this way: import rasterio lons = [66.979, 69.2979, 67.2979 ] lats = [36.5854, 40.9854, 37.9854] ...
0
votes
1answer
52 views

Write Zonal Statistics as table to an editable table in Python

I am performing zonal statistics as table on many rasters (different years of data). I would like to write the result to a table that I can edit, so that I can rename the "SUM" column and left join ...
1
vote
0answers
126 views

Viewing GeoPandas Dataframe in VScode or PyCharm like Pandas Dataframes

I'm not sure if this is a missing feature or something that I couldn't figure out so I wanted to get some help; I started learning geopandas library, now I'm following some tutorials I realized that ...
-1
votes
2answers
51 views

Join dataset to geography in Carto (Python)

I'm subscribed to two datasets and one geography on Carto Data Observatory. How can I join them to each other using Python? I have converted both datasets and geography into pandas dataframe, then ...
3
votes
1answer
482 views

Merging a geodataframe and pandas dataframe based on a column

I have a simple geopandas dataframe that includes geometry and a column called 'MUKEY': merged_spatial_df.head() I want to merge it to a tabular (.csv) pandas dataframe (which also has a column ...
0
votes
1answer
558 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 ...
1
vote
1answer
378 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['...
2
votes
0answers
81 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
28 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','...
3
votes
2answers
99 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
5k 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
205 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\...
3
votes
2answers
704 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
17 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
47 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
62 views

Loading GeoDataFrame to PostGIS when GEOM column contains MULTILINESTRING and LINESTRING [duplicate]

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
206 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
37 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
118 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
1k 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
242 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
100 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
38 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 ...