Questions tagged [for-loop]

A for-loop statement is a programming loop statement that performs predefined tasks while or until a predetermined condition is met.

Filter by
Sorted by
Tagged with
1
vote
1answer
46 views

Speed up Python script

I am using Python code to calculate the closest facilities. Here, first I create a random point dataset. Then I use that random point dataset as an incident dataset when I'm creating the closest ...
0
votes
1answer
24 views

Geolocating and writing many TIFFs at same time using R

I have found a way to give a PNG the CRS and location of a geolocated TIFF, and to convert the PNG to TIFF. Now I have to apply it to different PNGs in the same folder (all named Pt6_frame1, ...
1
vote
0answers
26 views

Process 100 of feature classes through script and fc name to end of each output

I have about 100 tiled 'area of interest' polygons in a geodatabase that need to be processed through my script. My script has been tested on individual tiles & works great. I need advice how to ...
0
votes
1answer
43 views

Using expression operators in if/else conditions without getInfo in Google Earth Engine

İ have a two-segment list with id and value and i want to make a new list from imageList using second element value. i want to get the first values in first column until 100 in second colum and save ...
1
vote
1answer
20 views

Work with individual Polygons of a SpatialPolygonsDataFrame (R)

I'm trying to work with individual polygons of a SpatialPolygonsDataFrame (SPDF). I've seen these two questions: Using sapply on SPDF and a for-loop on a SPDF. The latter I thought may be helpful, but ...
1
vote
1answer
33 views

Nested for loop ArcPy

I have multiple GDBs from an earlier process. Each GDB contains a single feature class (FC). I want to copy (FeatureClassToFeatureClass) each FC into a "Main" GDB for later processing in a ...
2
votes
1answer
46 views

Raster calculation with Python QGIS

I have this code in which I would like to perform a for loop in which every time I get one raster as input (the one called L, different for every month) and divide it always by the same raster (the ...
2
votes
1answer
38 views

QGIS Python raster calculator

I would like to run this code that makes calculation at every loop between different input rasters and Itot that is a raster that in the loop remains always the same. The code doesn't give me any ...
2
votes
1answer
43 views

Display GeoPandas on rasterio doesn't work inside loop

I have written a loop that suppose to open raster from file, display it as rgb and then plot on top of it GeoPandas plot. The problem is that the plots do not appear on to of the rasters inside the ...
0
votes
1answer
105 views

Sum of multiple rasters in QGIS Python

I would like to make the sum of 12 different rasters to get one raster as output. I wrote the following code but it doesn't work (or better, it works, but at the end it doesn't give me any layer, but ...
2
votes
1answer
65 views

Composite band through Batch processing using Sentinal 2 data in arcpy

As we know sentinel satellite data have many sub folder. I want to create composite band of each datasets with the band 2, band 3, band 4, band 8 which are located in one folder(10m) and band 11, band ...
2
votes
0answers
56 views

QGIS Python script with raster calculations

I have a problem with this code, that works, because it gives me the output rasters that I want, but the problem is that these outputs show wrong values because they are all 1.79769e+308. I think the ...
0
votes
0answers
54 views

Apply function to calculate NDVI on list of images

I'm looking for a simple for-loop to apply a function to create NDVI images from an original list and save those in a new folder. I've created a function and show how I would apply it on one image but ...
0
votes
1answer
57 views

Display and label a stack of Sentinel 1 images with the date [closed]

I have a stack of Sentinel 1 images and I want to display all of them one by one and want the label to be the date of corresponding image. I am trying a for loop for that but I am unable to visualize ...
2
votes
1answer
68 views

Copy multiple shapefiles that intersect a polygon to a new location

I am trying to select and copy shapefiles from one folder to a new location based on if they intersect a polygon feature class. I am getting stuck in somewhere in the for loop. EDIT: The goal is to ...
4
votes
1answer
98 views

Error in r: “mean” is not a valid subset when averaging over years in a raster

I am using a moving window average to estimate change between historical climate (here, a 36-year average for a period) and the moving window averages of climate into the future. Each moving window ...
2
votes
1answer
46 views

When calculating a field in an attribute table, how can I find one value out of many fields when every other field has a null value?

I have 4,018 rows of data with about 50 fields. About 45 of those fields are the same variable, but the data came from different layers, so out of those 45 fields, only one has a value for the row, ...
2
votes
1answer
43 views

Using 2 different for loops in Python, skips second process

I am trying to do the following in Python 2.7: Clip all files in a geodatabase with a single layer (so a batch clip) Export the resulting clip layers (identified with _clip on the end of their names) ...
0
votes
1answer
29 views

Using loops within an equation for Python and inputting values into QGIS [closed]

I would like to incorporate the use of loops within my Python coding equation. I am looking to find the value for the radius (distance) for multiple earthquakes and their corresponding intensity ...
0
votes
1answer
23 views

Error while exporting plots results from cor function in a for loop over subfolders

I'm trying to plot the results from cor function that is running over multiple subfolders that contain TIF files. The process I have followed so far didn't work. It seems there is a problem while ...
1
vote
1answer
133 views

Naming raster layers in a rasterstack with the same name

I have a for loop where I loop layers from a rasterstack into a predict function, which requires the output of a model and two raster files, including one layer for the present ("rastFile") ...
1
vote
1answer
124 views

Subset by year in a raster stack, save individual raster stacks, & then loop into biovars function in R

I have raster bricks of monthly max temperature, min temperature, and precipitation for various time periods (e.g., from 2090-2100, in this example). > tmax class : RasterBrick dimensions : ...
1
vote
0answers
221 views

Converting every pixel of TIFF file from decimal to binary

I have a folder of .tif-files. I would like to convert every value in each of these files from decimal to binary. This code mostly works. The inner loop correctly outputs the binary equivalent for ...
1
vote
1answer
69 views

For loop for access to a directory files in ArcPy

I have a Python Toolbox and I want to use a directory to read different shapefiles. But when I run the script It only works for the first shape. fd is the directory and the code is: fd= parameters[0]....
0
votes
2answers
184 views

I want to create composite band image through batch processing using ArcPy

I have multiple Sentinel 2a raster images in separated folders at same location, which means every image is in separate folder. Now I want to create composite band of each raster. I have written a ...
-1
votes
1answer
150 views

Creating composite band image form multiple Sentinel 2 raster data using ArcPy

I have multiple Sentinel 2a raster images in separated folders at same location, which means every image is in separate folder. Now I want to create composite band of each raster. I have written a ...
3
votes
1answer
38 views

Spatial join features from different geodatabases

I have two geodatabases with several feature classes in both of them. I want to spatial join the feature classes in gdb1 to those in gdb2. I tried to use "arcpy.ListFeatureClasses()" ...
3
votes
2answers
85 views

I want to create NDVI of multiple raster using ArcPy

I have multiple raster data which are layer stack. Now I want to create NDVI of each raster data. I am stuck in the code, I developed a script but dose not generate any output. import arcpy, os from ...
0
votes
0answers
160 views

ERROR 000582 from clip processes in ArcPy

Durring execution of clip in arcpy, an error has occurred. It is showing ExecuteError: ERROR 000582: Error occurred during execution. import arcpy arcpy.env.workspace = (r"L:\\Arcpy\\Data\\...
1
vote
1answer
76 views

Clip raster data by multiple shapefile in ArcPy using Clip data management tool

I have one raster data of a state and also I have 14 shapefile in same area. Now I want to clip 14 shapefile in arcpy using for loop. The issue is when I run the script its showing TypeError:'NoneType'...
0
votes
1answer
90 views

Using st_distance with apply functions and iterators

I'm working with a dataset of islands in which I need to calculate the distance between each island and the nearest landmass with an area greater than that island. I can do this successfully with a ...
0
votes
0answers
325 views

How to loop through a list of lists and safe the output coefficiants?

I have split a list of NDVI and climate data into small csv. files with 34 years of data each. Every 34 years should be split into two parts depending on a conflict year, saved in the same table and a ...
2
votes
3answers
120 views

Including float value in loop processing of Surface Volume tool using ArcMap ModelBuilder

How do I use the Surface Volume tool in ArcMap via Model Builder, without using Python, to process a set of multiple float values in a loop, since an iterator takes integers when I implement a for ...
1
vote
1answer
79 views

Create new shapefile for each unique attribute using for-loop with PyQGIS?

I have a roads shapefile. In its name field, I'll create a new shapefile per attribute. I already got each unique attribute under name. The for-loop that iterates over the unique attributes and ...
2
votes
1answer
2k 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
0answers
22 views

Concatenate from all the elements from a list of lists to have a string [duplicate]

I have data from a JSONs like as below data={'type': 'Feature', 'geometry': {'type': 'LineString', 'coordinates': [[410910.0885459831, 2479395.4132211693, 0.0], [410903.8088855865, 2479401.860380645,...
0
votes
1answer
58 views

Python 2.7 stand alone script for compounded with statement. Errors 'column specified does not exist - but it does

I'm writing a standalone Python script to use for labeling ArcMap 10.7 data. (Want to avoid label expressions for portability, etc). I'm attempting to use ID attribute to label based on ADMIN_ORG ...
2
votes
1answer
84 views

How to put this in a for-loop? I'm recreating ArcMap's 'Tabulate Area' tool in Python

I have two shapefiles, a province with 39 municipalities and a land cover of the province. Goal: get the sqm of each land cover classification for each municipality. For example, how much open forest, ...
2
votes
0answers
41 views

Use graphical modeler to loop through CSV columns

I'm looking for a way to loop through the columns of my CSV and implement this function that I made in the graphical modeler in QGIS. I have two layers: (1) the map layer and (2) the delimited text (...
0
votes
1answer
324 views

Applying the censusgeocode Package to an Entire Dataframe of Geocoded Data

I have a data frame of latitudes and longitudes. The goal is to apply the censusgeocode package to the entire data frame where our x is our latitude column and our y is our longitude column. After ...
0
votes
0answers
26 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 ...
0
votes
2answers
302 views

Loop to sample random points within several polygons in R

I have a shapefile with 6 polygons, each one with a specific id. I want to create random points within these polygons, but with different sample size (each id has a specific value). The file with ...
1
vote
1answer
24 views

Publishing multiple CSVS as uniquely names feature services

I'm supposed to publish each file as a uniquely names feature service, but despite my approach I keep having issues where my csv files aren't found... a friend advised me to add my initials to each ...
1
vote
1answer
170 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 ...
2
votes
1answer
34 views

Joining one field from multiple feature classes to another feature class

I've got 19 feature classes, with a single field in each one that I am interested in. I want to pull that field from each one (index 63 on each feature class), and join those fields to a single ...
1
vote
0answers
81 views

ArcPy for loops increase duration with each iteration

I am running an ArcPy script with IDLE 2.7 For each line in a geometric network, it traces the path to a fixed location from that input line. For each input line, it does this trace with all other ...
1
vote
0answers
56 views

Creating a for loop to publish multiple CSVs as feature services? [closed]

I have multiple CSVs that I want to publish them each as unique feature services. Instead of publishing them one at a time, I'm trying to find the correct syntax to create a for loop. This is the ...
0
votes
1answer
50 views

Error in for loop not recognizing writeLAS command

I am currently trying to run a for loop in R that creates las files from a vector of 530 objects (EABplots). I have downloaded lidR, rLiDAR, and the relevant packages that come along with them (sp, ...
0
votes
0answers
24 views

Export Features by Unique Value Tool

I'm a new python user trying to build a script tool for an ArcPro project. The Tool will allow a user to select specific field data from a feature class and then export it as a new feature class to a ...
1
vote
1answer
358 views

Error: Image.reduceRegions: Unable to find a crs. within a loop in Google Earth Engine

I am trying to get daily estimates for AOD per Census tract in CA from the year 2000-2015. When I run the loop to filter to the daily level. I get the Error: Image.reduceRegions: Unable to find a crs. ...