mask

How to make binary mask of large .tif file fast using .shp file with polygons (GPS coordinates)?

How to make binary mask of large .tif file fast using .shp file with polygons (GPS coordinates)? Question: I have a large .tif file (~24 Gb, more, than RAM could store) (Similar question: https://rasterio.readthedocs.io/en/latest/topics/masking-by-shapefile.html) (Method from library: https://rasterio.readthedocs.io/en/latest/topics/masking-by-shapefile.html) But I’m searching another faster solution. Maybe I should create numpy array with zeros and add polygon …

Total answers: 1

numpy.all strange behaviour

numpy.all strange behaviour Question: In the following code, I try to generate a mask on an image. The mask should only be true where the image (originalFormat, ndarry with shape [720, 1280, 3]) has a specific value (segmentId, nd array with shape [3,]). Here’s a small part of the code as minimal example: originalFormat = …

Total answers: 2

How to extract coordinates falling in a bbox from a geopandas data frame?

How to extract coordinates falling in a bbox from a geopandas data frame? Question: I have a geopandas dataframe with coordinates and long with data frame I have a bbox. Now I want to apply the bbox on the data frame and extract the coordinates that’s falling in that bbox. I tried using gpd.clip to …

Total answers: 2

What is the fastest way to filter a pandas time series?

What is the fastest way to filter a pandas time series? Question: What is the fastest way to filter a pandas time series? For now I use boolean masking to filter the time series ts: import time from datetime import datetime import pandas as pd import statistics # create time series idx = pd.date_range(start=’2022-01-01′, end=’2023-01-01′, …

Total answers: 1

Replacing ones and zeros in a 2D numpy array with another array?

Replacing ones and zeros in a 2D numpy array with another array? Question: I have a simple problem that I am trying to solve using numpy in an efficient manner. The jist of it is that I have a simple 2D array containing ones and zeros representing an image mask. What I want to do …

Total answers: 3

How can I remove the rows of my dataset using pandas?

How can I remove the rows of my dataset using pandas? Question: Here’s the dataset I’m dealing with (called depo_dataset): Some entries starting from the second column (0.0) might be 0.000…, the goal is for each column starting from the 2nd one, I will generate a separate array of Energy, with the 0.0… entry in …

Total answers: 2

Fast way to iterate and apply condition thought dataframe

Fast way to iterate and apply condition thought dataframe Question: I have a large dataframe such as below: vehicle id delta 0 0 0 1 0 20 2 0 40 3 0 400 4 0 10 5 1 0 6 1 10 7 1 500 8 1 10 9 1 10 10 1 100 11 …

Total answers: 4

Reconstructing image from mask coordinates

Reconstructing image from mask coordinates Question: I have a Boolean mask (i.e. mask1) in a Numpy array. Its shape its as follows: Then, I have the following code to extract the x and y coordinates of all the pixels within that mask xy_coords = np.flip(np.column_stack(np.where(mask1 > 0)), axis=1)#getting coordinates of pixels within the mask For …

Total answers: 2

Pandas select rows with smaller index

Pandas select rows with smaller index Question: Here is I think a simple question, But I can’t find an answer. I’m trying to set a few rows from a dataframe using a mask of a mask. but I get an "Unalignable boolean Series provided as indexer" error. Here is a small example: import pandas as …

Total answers: 2

mask and apply numpy where function to a vector in c++

mask and apply numpy where function to a vector in c++ Question: I’m using C++ and want to combine the masking of a vector and the search for the indexes where a condition is verified, similarly to the numpy where function. Here’s an example: std::vector<int> id = {61, 66, 68, 80} std::vector<int> val = {0, …

Total answers: 2