Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [loop]

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

0
votes
0answers
23 views

Importing CSV to shapefiles using loop?

I'm adapting this code to import a folder of CSV files to shapefiles. Error thrown at "for row in reader:" is "ValueError: I/O operation on closed file" Not sure if this means the CSV files closed so ...
0
votes
1answer
25 views

Loop through two raster datasets by order and perform a function

I have two raster datasets that I need to loop through by order and select the first raster from the first dataset with the first raster from the second dataset to perform a function. I keep getting ...
0
votes
1answer
22 views

Export raster over a loop in Google Earth Engine

I would like to export raster in a foreach loop with : var landCover = ee.Image('MODIS/006/MCD12Q1/2016_01_01').select('LC_Prop1'); var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017'); ...
0
votes
0answers
11 views

Extract values from multiple rasters based on lookup of raster file name

I have 11 raster files (waveheightfiles), and need to extract one value from a different set of coordinates (station) for each raster. I have a list of 11 coordinates (df2) and have used part of the ...
0
votes
1answer
20 views

Looping a function over a sequence of parameters with iterate()

I built a function landcov(area, date) to calculate the share of land types 0 to 3 in year "date" from MODIS12Q1 within the polygons of the "area" parameter. I want to use iterate() in a loop-like ...
1
vote
1answer
71 views

Looping Eliminate tool in Python?

I am very new at Python,I'm not sure if this is even the appropriate way to do what I want to do, but basically, I'm looking to eliminate all of the small polygons in a feature class that was created ...
1
vote
2answers
79 views

Looping through a table to allocate kids to nearest school

The general problem is to allocate town's kids to their nearest school and get the distance and the geometry. Tools in use is Postgresql 10.6, PostGIS 2.4.3 and PGRouting 2.5.2 There are three ...
0
votes
1answer
36 views

Using for loop in least cost path analysis using ArcPy?

I am doing a least cost path analysis. I need to create a for loop that will run 3 times and select the correct weight from each of the two lists (slope and land). Slope = [10, 20, 30] Land = [30, 20,...
0
votes
0answers
62 views

Connditionally extract values from raster brick in a loop using R

Quick story I have multiple netCDFs representing different time periods, and a dataframe containing observations (point data) taken at different time periods. I would liek R to only extract data from ...
0
votes
1answer
68 views

turf.js point never found inside or within GeoJSON features loop

I have a GeoJSON http://radikal.com.mx/distrito.json and all I am trying to do is find if a turf point that has a longitude and latitude is inside or within that GeoJSON. No matter what point I use I ...
1
vote
1answer
60 views

Calculate difference of subsequent images in a collection

how do I call a Specific Image inside a Collection, to loop over it? this is for calculating the difference of images for each set of two subsequent images in a collection dImage= Image(t=i+1)-Image(...
0
votes
0answers
8 views

ogr2ogr loop through feature classes in FGDB except one feature class

I have multiple fgdb and I wanted to merge this to one FGDB and this is the command I used so far find . -path "*/*1*/*.gdb" -o -path "*/*2*/*.gdb" -o -path "*/*3*/*.gdb" \ -o -path "*/*4*/*.gdb" -o -...
0
votes
2answers
31 views

Arcpy UpdateCursor not Updating, but no Error Reported

Below is the code I'm using in an SDE GDB, on ArcMap 10.4.1: import arcpy # Variables inputAsbuilt = arcpy.GetParameterAsText(0) transmedia = inputAsbuilt + "\\Transmedia" structure = inputAsbuilt + ...
4
votes
1answer
269 views

Iterate through list of field names and calculate fields with PyQGIS?

I am using QGIS 3.2.1 Bonn 64 bit on Windows 10. I would like to loop through a list of field names and perform calculations on each field. Only the first loop in the iteration performs any ...
1
vote
1answer
59 views

calculation with raster and numeric values in Loop with R

I want to do some calculations with a list of rasters of lakes. Therefore I wrote a loop, which has so far worked fine when I only used rasters. Now I have calculations with rasters and numeric ...
1
vote
1answer
123 views

Creating a Loop in R for averaging Raster values to create time series

I have calculated several different indices for lakes stored as GEOTiff. I now want to write a loop with R to average the values for each lake, so only one value is left for each lake. And then create ...
1
vote
1answer
32 views

Reducing monthly averaged MODIS data over several ROIs

I want to create monthly averages for the MODIS Land Surface Temperature (LST) product for several ROIs. I am able to create an image collection containing the monthly averaged MODIS data, but I have ...
0
votes
2answers
32 views

R: Writing individual variables from a RasterStack in loop

I have a RasterStack with 3 layers each one of them containing 19 variables. Using writeRaster I need to save specific variables into my directory while naming the saved files with the actual variable ...
0
votes
1answer
24 views

gdalwarp for clipping images using multiple polygon in a bash shell for loop

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570003d29ed0dc.shp -crop_to_cutline -dstalpha -tr 0....
0
votes
0answers
49 views

Saving rasters in Arcpy loop

I'm trying to do Map Algebra on a bunch of rasters by iterating through a for loop and saving them in an empty geodatabase. However, they aren't saving properly. Only the last raster is created and it ...
2
votes
0answers
54 views

Map Algebra loop only creating one raster

I'm trying to transform a bunch of rasters in arcpy according to specific functions to create suitability rasters. This portion of the code is supposed to find all the rasters with interpolated ...
1
vote
2answers
146 views

Batch Calculating Indices

I have 111 Landsat8 scenes which I want to calculate several indices for. The algebra to calculate them is most of the time Index= (b1-b2)/(b1+b2). I have the single bands (bands 1-11 respectively) ...
3
votes
1answer
80 views

Can't do anything else in QGIS during While-Loop

I've written a Python QGIS plugin that reads data from an AIS receiver via the Serial package. It will be similar in function to the GPS Information panel in that it will show your position on the map ...
0
votes
1answer
111 views

Running MaxEnt modelling in “dismo” using “loop” and storing the results in seperate objects and folders [closed]

I am doing a MaxEnt modelling using "dismo". I am using a loop to give multiple runs. I wanted to save results from individual runs in separate objects and at the same time the results from individual ...
-1
votes
1answer
28 views

Writing Nested Loops Using SelectLayerByAttribute_management Iteratively over Multiple Fields?

I need to select all rows matching specific values across 3 columns and then iteratively change one value at a time and continue making selections. The reason is to capture certain summary statistics ...
0
votes
1answer
178 views

Applying a Loop for my code in R

I am trying to apply a code (in R) for all images that I have in a folder. The code works for 1 image, but when I try to make a loop out of it, it gives me error. library(raster) library(rgdal) ET<...
-1
votes
2answers
50 views

Script Python on ArcGIS works but do nothing [closed]

I am trying to automate a loop for the Alter Field tool. As the code snippet that comes with the help fits my problem, I used it by changing the workspace path. I also tried passing the path with ...
0
votes
1answer
59 views

Combining two models, one having an iterator

I have two different ModelBuilder models: Create a new field and split a layer Merge all layers in one folder I want to append both models in one but it does not work. The Model have a loop and I ...
0
votes
2answers
142 views

how to loop ndvi using R in sentinel-2

I have a two different stacks: one for band 4 (RED) and other with band 8 (NIR). I'm trying to loop the calculation of NDVI in an area of interest using R. Well, this is the loop that I'm trying to ...
0
votes
1answer
40 views

Loop For to export polygons from a Feature Class

I need to export 150 polygons from a feature Class. I have a python snippet code to export the polygons one by one. I think a for loop code can do it fast, but I don't know how to write the code into ...
0
votes
1answer
50 views

ogr2ogr apply sqlite dialect to multiple feature classes within a fgdb

I have a quite many feature classes in a filegdb and they all have same data schema (same field names and etc). I wanted to apply a single sqlite query and I am having hard time to make a loop ...
0
votes
1answer
62 views

Reproject all layers in a spatialite file using ogr2ogr

I would like to reproject all layers in a spatialite file from one srs to another srs. Is there a way I can archieve this without parsing the layers names to a txt-file? I know I can write all ...
0
votes
2answers
72 views

Selecting layers of a raster stack using a sliding windows as a step in R in for loop

I would like to create a loop that every time selects the first ten layers of a raster stack, calculates their mean and saves it to a layer of a new raster stack. Also, I would like to have a step ...
2
votes
2answers
133 views

GRASS r.in.lidar (las to raster) inside Python loop?

I have a loop in Python to list out LAS files in a folder, and run two commands in Grass GIS on these files to write them out as rasters. The loop runs but at the end I get an arg must be string not ...
0
votes
1answer
34 views

Looping Sub-folders to merge shapefiles export by sub-folder name to file geodatabase [closed]

trying to loop through folders, merge shapes in folders, naming my folder name, export to feature class in file geodatabase. **merge loop** import arcpy from arcpy import env import os **Workspace*...
0
votes
1answer
80 views

Batch clipping with multiple shapefiles in ArcPy?

I am trying to create an ArcPy script to clip multiple shapefiles (2,000) to the census tracts in LA County. I have successfully run the code on a single shapefile and am trying to convert the code ...
0
votes
1answer
395 views

ModelBuilder: Error 999999 “Failed to copy raster dataset”

I want to run the "Project Raster" tool in the ModelBuilder of ArcMap but I get the "ERROR 999999: Error executing function. Failed to copy raster dataset." and I have no reason why. Input is a ...
1
vote
1answer
53 views

ArcGIS ModelBuilder looping wrong tools?

I've created a toolchain in ArcGIS ModelBuilder (see in the picture) But after Creating the "Flow Direction" and the "Iterate field Values" it starts again with the "DEM reconditioning", it's an ...
1
vote
0answers
34 views

Creating separate shapefiles for each attribute record using loop in ArcPy? [closed]

Line 24 fixed, final code now updated. Line 22 since fixed , now I get the error Traceback (most recent call last): File "C:\Users\shehn\Documents\ArcGIS\PyScripts\lab6X.py", line 24, in arcpy....
-2
votes
1answer
143 views

Looping for NDVI in different file paths using R? [closed]

I have different bands separated in different file directory. I used Raster Calculator to calculate NDVI using "NIR1.tif"-"RED1.tif"/"NIR1.tif"+"RED1.tif" as formula. The link below describes a loop ...
4
votes
3answers
557 views

Looping if condition in ArcPy?

I want to use "Calculate field" based on the string in another field. I would like to loop if condition but something is wrong and I am little bit confused. I am super new in Python. Here is my ...
1
vote
1answer
79 views

Saving output in ArcPy?

The loop runs once, then i get this error message. Runtime error Traceback (most recent call last): File "<string>", line 17, in <module> File "c:\program files (x86)\arcgis\...
1
vote
1answer
59 views

Looping script with Zonal Statistics

This is my first time using python in ArcGIS. I have a gdb of about 100 feature classes, and need to get Zonal Statistics for each. I'm using a textbook, and got this so far: import arcpy from arcpy ...
1
vote
0answers
409 views

How to loop the kernel for covering all pixels from a raster in 5x5 convolution window by using OpenCV? [closed]

Here, I have python code which is helping me in selecting 5 by 5 window from upper left corner of a raster (.tif). I want a process to automate through entire image in 5 by 5 convolution window. ...
0
votes
2answers
34 views

How do you create a loop that assesses if the number is greater than 5. The list [7,2,9,3,1,10,8,6,4,5]? [closed]

x = [7,2,9,3,1,10,8,6,4,5] for number in x: if x > 5: print x This is all I got. New to python. The output just gives me the list again
3
votes
1answer
833 views

Raster calculation loop - R

I have a raster stack of 108 elements The stack 'images' is created using 4 bands (RGB+NIR) of 27 satellite images. The sequence of the rasters in the stack is: Position [[1]]: blue band image 1 ...
1
vote
1answer
1k views

Python - Convert csv with unknown number of columns to shapefile

I have this script that converts a csv file to a shapefile. In this case I am specifying manually the name of columns header. Since now I have files with a big and always different number of columns, ...
0
votes
1answer
53 views

Save lappy results without overwritting - R

Here is my situation, I have 10 multi-spectral images. For each one I am calculating three different vegetation indices. Those 3 raster objects share resolution, projection, extent and dimension (...
1
vote
2answers
957 views

Looping several raster files in R

I have to create several canopy height model (CHM) rasters from DTM & DSM rasters that are stored in different folders. The problem is that I have to repeat the process for more than 300 rasters. ...
3
votes
1answer
82 views

How to create field calculator expression in a joined table using ArcPy

I want to calculate values within a field for a table (tableE) based on values of the field of another table (tableS) and within a loop: Basically I create two lists of tables: table_EMISS and ...