Questions tagged [loop]

A sequence of instructions that repeats either a specified number of times or until a particular condition is met.

Filter by
Sorted by
Tagged with
1
vote
2answers
97 views

Writing PyQGIS script with operations on multiple set of rasters

I would like to perform a loop that takes from a given folder a set of rasters and for every raster makes the following operation, that in the specific case is the calculation of the monthly ...
3
votes
1answer
32 views

Conditional statement in R based on multiple rasters

I have: raster_1: an integer raster with non-sequential values i (101, 130, 240, 323) i: a watershed discharging X of sediment in the environment raster_2: represents the water quality for each ...
2
votes
1answer
30 views

Error when calculating final polygon after subtracting all intersecting polygons using shapely

This question is a follow-on question from Calculating final polygon after subtracting all intersecting polygons using shapely which was answered. I have a list of centroids that I buffer to 5000 ...
2
votes
1answer
44 views

Calculating final polygon after subtracting all intersecting polygons using shapely [closed]

I have a list of centroids that I buffer to 5000 meters radius. I need to take each resulting circle and run it against the remaining centroids(also buffered to 5000 m) and find the final shape after ...
4
votes
2answers
47 views

Looping with a range of integers for 'numeric' inputs in QGIS Python Console

I have been trying to run r.sun.incidout in a loop of integers (for the 'Day' option, type=integer) in QGIS Python Console. Since the 'day' parameter takes an integer number for its value, I get the ...
1
vote
0answers
28 views

Extracting raster NDVI images for summer months over several years (GEE and LANDSAT)

I want to extract NDVI raster image that is including only NDVI band over a certain region (noted as point) for summer months over several years. I am working with Landsat 8 and the time frame is June,...
1
vote
0answers
38 views

Loop does not run in QGIS action

I tried to create a QGIS action in order to refresh several materialized views at once. for that I wanted to execute a simple loop in my action in order to recover the database where the view will be ...
1
vote
1answer
121 views

Invalid Number Error in Google Earth Engine?

I wrote the below code for sentinel5 data, but returns Invalid Number error in monthly loop. It used to work very well but now shows error. How can I fix it? code link: https://code.earthengine....
0
votes
1answer
45 views

Google earth engine: function to apply code to sequential dates

0 I have a code which creates a value for several different variables for a specific time period (usually over 1 month) and exports these as a csv to my google drive. You can find a link to the code ...
0
votes
1answer
73 views

Execute loop in PostgreSQL query

How to execute for each table in the list one fixed query replacing just %table% in PostgreSQL (like variables and loops) sql = 'select * from $table$ where...some_filter' $table = {tb1, tb2, tb3...}...
1
vote
1answer
56 views

Is there any fast looping through too many shapefiles in a folder using ArcPy?

Looping through shapefile using arcpy.ListFeatureClasses() is very slow for many shapefiles. because first thing first, it writes all in memory as a list and then read each shapefile one by one. Is ...
1
vote
1answer
36 views

Loop through directories and mosaic all raster TIFFs in each dir

I have 200+ directories, each directory contains x amount of TIFFs which I want to mosaic. I have a snip of code that will list the TIFF contents of all dirs under a parent directory, now I just need ...
0
votes
1answer
167 views

Remove Images from Image Collection in Google Earth Engine?

In the below code, I'm going to remove some images from image collection by if condition in .map() instead of filter.neq(), what should I do for this purpose? Map.centerObject(table); Map.addLayer(...
2
votes
1answer
67 views

How QGIS Python loop through all tables MS SQL Server?

I've got Python code on QGIS 3.12 that adds a MS SQL Server data layer to the map, but I need to add all of them. uri = QgsDataSourceUri() uri.setConnection(r"xx.xxx.xxx.xx\xxx", "xxxx&...
1
vote
2answers
87 views

How can I restart the loop or skip the error?

I set up a loop to extract cloudiness in multiple places, but if there is no image in one place in the loop, GEE will report an error.I want to loop to a place where there is no image and the loop can ...
2
votes
1answer
520 views

Call a function multiple times with different argument for date

I need to call the same function 10 times, each time with a different year for the end date argument. For example, the end date needs to start as "2011-01-01", then "2012-01-01", ...
0
votes
1answer
68 views

Creating a Python loop to add up automatically generated rasters on QGIS 3

I'm creating a QGIS 3 program that extracts flow paths from a DTM, then slightly modifies the DTM to extract new flow paths that I want to add to the previous flow path raster. I have used the ...
3
votes
2answers
35 views

Extracting poly.counts through loops using R

I want to extract the count of points over Africa at the first administrative district level at monthly intervals over 26 years. My point data consist of conflict events. I am struggling to figure out ...
0
votes
0answers
45 views

Working around “Unable to allocate memory” error during for-loop in Arcpy

I'm running a very long for-loop in Arcpy (with ArcGIS 10.7 on Win10) over several ten thousand files. It runs smoothly until, everytime after about 3000 iterations (3-4h), it crashes with the error ...
1
vote
1answer
81 views

Recursively find all GeoTIFF in current and subfolders and clip using GDAL

I have thousand of GeoTIFF file in subfolders, and I would like to crop all of them using shapefile and save in a Crop folder. My working directory is: /Data/2000/image_20000101.tif /Data/2000/...
3
votes
1answer
58 views

Iterate through dates and through columns using Model Builder of ArcGIS 10.x

I have a point feature class in a geodatabase (approx 11000 features) with 366 columns. From these, one represents the targeted date and the other 365 represents the temperature of one day of the ...
0
votes
1answer
78 views

R: How to standardise extent of rasters for raster stack

So I'm trying to build a raster stack of 7 variables. In ArcMap I've already standardised resolution and CRS, and I tried to standardise extent and column/row number by extracting by mask with a ...
0
votes
0answers
24 views

Create a loop to run and store the r.stats output of several viewsheds?

I have 15 viewsheds (view 0-14) from which I would like to export the cell count. I can do this for one viewshed through: count=[] i=0 viewshedSize=grass.read_command("r.stats", overwrite=True,flags=...
0
votes
0answers
25 views

Summarizing Continental Biome Data in R

I have written code the produces a mean threshold value for the amount of satellite imagery needed in a single year to produce the 95th percentile of NDVI. I assume that this threshold of satellite ...
1
vote
1answer
106 views

Loop to intersect points with polygons in R for each individual

I have a shapefile with points for 6 individuals and another shapefile with 6 polygons (one per individual). Every individual has the same id in both files. I want to intersect both layers in order ...
0
votes
1answer
135 views

Writing a for loop in r to process multiple rasters with quantiles values

I am trying to get R to read a folder containing raster files, and then in a foor loop, extract quantile values from each of the raster to enventually process each raster with a substraction involving ...
1
vote
1answer
42 views

Using ArcPy with Intersect and loop

I am new to scripting. I have around 4500 small shapefiles to be intersected with one big shapefile. The primary key is to make 4500 small intersected shapefiles. How to do it correctly by using ...
0
votes
1answer
31 views

Function to calculate time series wise max and min

I have image collection from that I want to make a loop function where I want to call all images that have the same temporal resolution but date range varies (like 2000-06-09 to 2019-06-17) through ...
1
vote
1answer
189 views

How do I create several concentric buffers in a loop in R

I am working with polygons and I need to create concentric buffers every ten kilometers until I reach a distance of 70 kilometers, in this sense I want only the 10 kilometers rings without the polygon ...
4
votes
2answers
2k views

How to mask NetCDF time series data from a shapefile in Python?

I have a 3-D time-series precipitation data (187 x 1800 x 3600), stored in a NetCDF file. I need to obtain the precipitation data for a shapefile. import matplotlib.pyplot as plt from netCDF4 import ...
1
vote
0answers
24 views

Loop on table to create Dynamic Layers

I am receiving a table with customer names, group of customers and some data. I need to create dynamically Layers of these groups, then add these customer to these respective groups, then display a ...
1
vote
2answers
65 views

Difficulty with select by attributes using list fields in for loop

I am trying to add fields to a table and then populate the fields with text values (Yes/No). The text values are based on whether or not a species was found in a specific block. If the species was ...
1
vote
1answer
49 views

Loops for calculating vegetation indices for multiple temporal images and each image have multiple bands

I have 64 TIFF files of different dates, each date has 4 bands (123 and 4 for B, G R and NIR). I am trying to develop a Vegetation index for each date image. This is how the images in my folder are [...
2
votes
0answers
161 views

Clipping Raster by Mask using PyQGIS

I'm trying to develop code that is capable of cutting out a mosaic from the polygons of a shapefile using PyQGIS. The script is run but does not produce any results. from qgis.core import * from ...
2
votes
1answer
38 views

Iterate through path type inside 'WHERE' statement

I have a table defined as following CREATE TABLE public.geometry_polyline_volume ( id serial not null primary key, distance float not null, height float not null, ...
4
votes
2answers
143 views

Different Results in GEE when using manually upload polygon and uploaded shapefile

I have a code that classifies polygons based on their NDVI values (based on mean and std, classes into 3 ranges: high, medium and low). The code suppose to do this process for each polygon, but I ...
1
vote
1answer
60 views

Calculate field with a value in a list based on field [closed]

I don't want to write an if statement for every field. I want to know if there is another way to field calculate each field with the values related to it in this example table: Fields (X,Y,...
2
votes
2answers
35 views

Is there any way to force a loop to go until the last list object in R?

I am running a loop in R to rasterize a list of data frames and for comparison purposes I have to keep the same list length in the output. I am facing some problems with NULL objects on the list. I ...
3
votes
1answer
172 views

Loop checking if attribute field exists in PyQGIS

I'm building my first script and I need help to create a loop instead of my repetitiv functions. The aim is to check if every field already exists, and to build it only if it doesn't. This script ...
-1
votes
1answer
54 views

ArcPy: Delete field loop with if exception

Am new to ArcPy , am trying to join the same features from different geodatabase but I don't need all of attributes, so want to make a loop to find each feature class and delete the fields I don't ...
4
votes
1answer
73 views

How can I process vector difference between 1 group layer and 1 polygon layer?

I have one layer group called 'left_buffer', containing 40 buffered polygon layers (name: 1,2,3,...,39,40). I want to use difference vector tool between 'left_buffer' and 'bldg' layer, but I'm getting ...
4
votes
1answer
92 views

Export looped layers at once using PyQGIS?

I am trying to use one-side buffer on road centerline (layer name: small_road) by 1~40m. I've succeeded in creating one buffer (2m) file at a time using 'SEGMENTS':2,'JOIN_STYLE':0,'MITER_LIMIT':2,'...
1
vote
1answer
414 views

Count the number of pixels according to their value using for loop

I have script that does the enxt procedures: create imagecollection from Landsat7 clip the images according to specific geometry and calculte NDVI for each one filter the rasters according to the ...
1
vote
0answers
15 views

Copying Features from multiple sources

I'm new to Python and trying to automate copying specified features from a bunch of nested geodatabases into a new geodatabase- script seems to work ok, except for the copying features part (the 2 ...
3
votes
1answer
96 views

Map algebra with loop and SetNull not working

I'm trying to run a loop through a number of rasters while using SetNull but keep receiving an error message. I have worked on these rasters individually using SetNull and it it works, but would need ...
0
votes
1answer
58 views

Use GDAL to resample and stack multidate image spectral bands

I have a Sentinel 2 multidate image data set and I'm trying to resample all of them at 10m and then stack them to apply a cloud mask, in Python language. Being new to programming, I have a hard time ...
1
vote
1answer
238 views

Iterate through raster in R and apply conditional statements

I have a raster data set in R with numeric values ranging from 0 to 61.5, including some random NAs throughout. I would provide a reproducible data set, but I don't know how to create a raster with ...
1
vote
2answers
61 views

Select_analysis Looping gives ERROR 000732

The script I use for select_analysis is no longer working. I believe part of the problem is the source data I use (and I'm not the administrator of) has changed the field properties of the attribute I ...
0
votes
1answer
34 views

Iterating through geodatabase and assigning field value based on spatial location using ArcPy - Part 2

This currently loops through my dataset and calculates the installation ID field from my dataset with the installation code from my Bragg Area feature that are within the polygon of each row. It works ...
2
votes
0answers
24 views

Iterator (Iterate Feature Selection) running loop in undesired path using ArcMap ModelBuilder?

I am building a model using Iterate Feature Selection. I want to run the Iterator -> select by location -> Calculate field, and after finishing this loop (#3 in the image below), I will continue to ...

1
2 3 4 5
7