Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [function]

A programming function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

Using elevatr and apply function

I'm trying to use the "apply" function with the R "eleavatr" package. I'm getting an error message but I'm not sure if the problem is in my understanding of the apply function (perhaps the root of the ...
1
vote
2answers
53 views

QGIS 3.4 feature filter maximum() does not work

I would like to filter a layer with the maximum value of field_a, grouped by field_b. I tried this expression: "field_a"= maximum ( "field_a","field_b") But it doesn't work (there are no more features ...
1
vote
1answer
28 views

Google Earth Engine: Error for mapping expression function over feature collection

I'm having an issue when trying to create a function to map over a feature collection. I'm trying to create SST thresholds for several regions where over a certain SST value is 1, under another SST, ...
3
votes
1answer
151 views

Difference between two vector layer

I have two vector layer land cover for 2016 and 2018. I want to get result layer that will show changes in land cover e.g. the forest has changed into a meadow. What option in QGIS can I do that. In ...
1
vote
1answer
70 views

Formula not vectorized, error in R [closed]

I have the following traceback and I would like some help to understand/solve it. Can anyone explain to me what to look here? 6: stop("cannot use this formula, probably because it is not vectorized"...
2
votes
1answer
54 views

Summarize Land use changes over time with Google Earth Engine

I'm trying to detect how many times land type has changed between 2001 and 2018 (inclusively). For example, suppose a pixel that was: Forest from 2001 to 2003 Bare ground from 2003 to 2010 ...
1
vote
1answer
66 views

Arcpy reclassify with function

I have two rasters, one with NDVI values, and one with greyscale values (=(red band + green band + blue band) / 3). The rasters have the same name. I need to reclassify them in arcpy with the ...
2
votes
0answers
42 views

Calculating line length to both sites in QGIS

Is there a function or a plugin for QGIS that works like this? I have a line, for example, 7 km I click on that line at any point A popup or something gives me the distance to the left an to the ...
1
vote
1answer
71 views

Using double offset in QGIS Expression String Builder?

I need to dynamically translate points 20 metres from their original point to a suitable cartographic position. I have a rotation value stored in a rotation attribute. I cannot use this tool right ...
1
vote
1answer
23 views

Apply function from rgeos package to data sets

I am using gDistance function from rgeos package to calculate the nearest distance from points to a polygon. Originally I used for loop to calculate the distance for each row in my points data set, ...
2
votes
2answers
58 views

Clipping Lines Using Expression in QGIS?

I have a set of roads that I wish to clip. How ever I only need a segment of each road based on the state its located in. I can do this independently but seems like there should be a better way. Ill ...
1
vote
1answer
50 views

Determining which layer in raster stack is first to meet condition using R?

I want to analyze a raster stack and determine the first layer in the stack that meets a condition for every pixel. Here's a reproducible code example generating rasters and making a stack. # ...
0
votes
0answers
21 views

What are the main uses or advantages or general definition of spatial functions in PostGIS? [duplicate]

After my search in website, I didn't find any solution for the general definition or uses or advantages of spatial function in PostGIS. I hope this question would help me in getting solution.
2
votes
0answers
54 views

Getting travel time while performing pgrouting i.e. what are parameters and function required?

While doing the pgrouting to find the shortest distance I got success in getting the output but when I thought to come up with the time consumed for travelling, I cannot find the proper source to get ...
0
votes
1answer
388 views

Why does Uncaught TypeError: Cannot read property 'trim' of undefined occur in esriRequest

I am trying to use esri/request to pull in some data from an API. I am have two weird problems. First, when I try to run this, it doesn't complete and throws the following error in the browser console:...
1
vote
0answers
58 views

How to create a function for getting a largest polygon from 2 polygons using case statement in PostgreSQL?

CREATE OR REPLACE FUNCTION public.largest_polygon1( geom1 geometry, geom2 geometry) RETURNS geometry LANGUAGE 'plpgsql' COST 100 VOLATILE AS $BODY$ begin Return Case ...
0
votes
1answer
58 views

Filtering area through defined time period using Google Earth Engine?

I tried the following code in the Google Earth Engine through the various countries which have different dry season. But I cannot understand how to iterate the code. can anyone generate iteration ...
0
votes
1answer
146 views

How to create a function for finding the largest of 2 polygons by area in PostGIS?

I tried my level in creating the function but it shows error while running. I have enclosed the code here : create function largest_poly (geom1, geom2) returns geometry as $largest_poly$ begin from ...
1
vote
1answer
34 views

Raster calculation over multiple layers using a function or do-loop

I have a bunch of raster calculations that are working, but there must be a more efficient way to do this with a do-loop or function. Essentially I have a bunch of combinations of: rates (county ...
1
vote
1answer
60 views

Seeking Function to calculate red-edgeNDVI in Google Earth Engine?

I am trying to calculate the red-edgeNDVI ((NIR – red edge)/(NIR + red edge)) of an Image.Collection in Google Earth Engine. There is a built in function for NDVI but not for red-edge NDVI. The code I ...
1
vote
0answers
42 views

QGIS 3.6: variable functions, confusing explanation

The documentation (https://docs.qgis.org/3.4/en/docs/user_manual/working_with_vector/expression.html#id31) says: To use these functions in an expression, they should be preceded by @ character (e....
1
vote
0answers
41 views

Error with generate_series

I`d like to create a Hex Grid using Hex grid algorithm for PostGIS (https://medium.com/@goldrydigital/hex-grid-algorithm-for-postgis-4ac45f61d093) DO $$ DECLARE _curs CURSOR FOR SELECT geom3857 ...
1
vote
1answer
79 views

Applying function to all files in directory using PyQGIS?

I have a problem for apply this function in all files. This script is about the extraction of the bands from a raster and I want to use it on all the file raster in the folder. It works on the single ...
4
votes
1answer
108 views

How to re-use an expression, stored as a string, in QGIS Field Calculator

As discussed in this question, QGIS automatically saves recently used expressions in the field calculator. But recently used expressions are deleted after a while. Sometimes I need to re-use an ...
0
votes
1answer
94 views

Google Earth Engine formaTrend function

So I'm using the formaTrend() function in Google Earth Engine to detect differences in forest cover over time (via long-trend). My question is if there's a paper or an explanation to what exactly ...
1
vote
1answer
91 views

Earth Engine how to avoid timeout for buffer calculation?

I have a function that takes a feature and creates a buffer around it. createBuffer = function(feature){ var AOI = feature.geometry().buffer(3000); return ee.Feature(AOI).copyProperties(feature)...
0
votes
1answer
161 views

Earth Engine create user defined function with default parameters

I am creating a user based function that I will save in my repository for re-use later. But I'm facing a problem with putting default values in my parameters. var myFunction = function(number, power ...
0
votes
1answer
53 views

IDL - calculate mean ignoring zeros [closed]

Imagine the following array: a = [10768,10764,10893,10763,10723,10792,0,0,0,0] Using a function like "MEAN" in IDL, is there a way to calculate the mean value, ignoring the zeros? I know this can ...
2
votes
1answer
241 views

Earth Engine - function for printing multiple histograms

I have several time periods within a feature where the precipitation was very low stored in a FeatureCollection with the properties "begin", "end", "amount", "days".I want to use the feature ...
4
votes
1answer
374 views

Creating function in function editor in QGIS

After my previous question Weighted values of field in QGIS, I successfully adapted the following formula in Expression dialogue "Value" / (sum("Value") / (count(CASE WHEN "Value" >= 1 THEN +1 END)...
0
votes
1answer
559 views

ImageCollection.map() with multiple input function

I have an Image Collection, I want to Calculate a Normalized difference and got this Function called ND /////normalized Differense/////// function ND(Im,B1,B2){ var four = Im.select(B1) var eight = ...
2
votes
1answer
56 views

Cross-schema function call with PostGIS dependencies

I have an issue where I am unable to make a cross-schema function call because of that function's use of PostGIS. I have both PostGIS and my function in the public schema, but I'm trying to call the ...
2
votes
1answer
473 views

Can you auto-populate a field in Survey123 from another field by only pulling certain characters?

I have a field where the user inputs text Aa1Bb2Cc3 Am I able to auto populate another field by only populating the field with Bb or 3. Auto populate the field with characters [4:6] or just [9] ...
0
votes
2answers
261 views

R: Reclassify a raster stack through the range of the quantiles of each layer. Generic quantiles function ; layer by layer

I have a raster stack that contains terrain bends extracted with different neighborhood windows "crosc_nxn" (e.g. 3x3, 5x5, etc ...). crosc_nxn <- raster::stack(path.files.list) > crosc_nxn ...
1
vote
1answer
177 views

image.substract is not a function

Link to GEE function BAI(Im){ var pcr = 0.1 var pir = Im.select('B3') var pcnir = 0.06 var pinir = Im.select('B4') var one = 1 var bai = one.divide(pcr.subtract(pir).pow(2).add(pcnir.subtract(pinir)....
1
vote
0answers
40 views

Summarize table by group and add logic to keep data

I need to dissolve a polygon layer by group but, at the same time, I need to keep some of the data in extra columns. This is the diagram: This is the logic for the new group: Cod = "Cod" where N1 ...
0
votes
2answers
50 views

Specific methodology to call a GRASS function like v.transform with Python

I cannot understand if and how I can call with its parameters a GRASS function like v.transform through a Python script from e.g. PyCharm etc. Is there something comprehensible to understand? An ...
0
votes
1answer
20 views

Making the results from function a string [closed]

I am trying to get the features count from feature, then put it in a dictionary that I can call later: ct_dict = dict() ... fipsList = ['13245','06007'] for fip in fipsList: mergedJoinCentroids =...
4
votes
2answers
2k views

How to extract a part of string from fields in QGIS field calculator?

I want to create a new field in my attribute table. My goal: returning all digits between the / and _ characters of the field named "location" by applying the next expression: regexp_substr( "Text", ...
0
votes
1answer
374 views

Setting “Map View” instead of “Split View” in Leaflet javascript

I am using geojson-dashboard framework template for Leaflet (http://fulcrumapp.github.io/geojson-dashboard/). By default, the initial view of the screen is "splitted" or "divided" (half view is the ...
3
votes
0answers
189 views

ST_Difference in PostGIS : problem with geometry result (Polygon)

I'm experimenting a result issue using the ST_Difference spatial function in PostGIS. Input : Feature 1 and 2 overlaps each other. Both contains 5 vertices, like a rectangle (4 plus an additional ...
0
votes
1answer
59 views

Two points that are the same

In my dataset there are two points that are identical in every way. I'm looking for a way to run some kind of query or functional attribute to make it such that there is only one point at this ...
1
vote
1answer
238 views

Updating PostgreSQL geometry column using SQL (Trgger)

I'm looking to inderstand the role of date_part('epoch'::text, now()) WHERE id=NEW.id; in the trigger function below. CREATE OR REPLACE FUNCTION fn_test_table_geo_update_event() RETURNS trigger AS $...
1
vote
1answer
296 views

NDWI and Cloud Pixel count

I am trying to add the (amount of pixels of) NDWI and Clouds as bands to my image collection. The NDWI works out, but I get stuck when adding the Clouds. The error refers to an incompatible number of ...
1
vote
1answer
26 views

Classifying text field 'B' using integer in field 'A'?

I wrote an if elif statement that will loop through records (field A) and populate a new field (field B) based on A's contents. Field A name is 'CLASS'. Field B is 'class_desc'. reclass(!class_desc!...
0
votes
1answer
200 views

Overview of available images per image collection?

I´m trying to make an overview in a table or graph of the available images in Landsat, Sentinel and Modis series for a certain area of interest. Although I could solve it as follows, this is obviously ...
1
vote
1answer
100 views

Filtering number of features in GeoServer using SLD?

I have published point file in geoserver from postgis table as store. I had huge data in my table(rows) and the data will keep udate daily (at least one point for one day). Now I want to show only ...
0
votes
1answer
227 views

Why is arcpy.ListUsers() not able to open SDE workspace?

I am working with ArcGIS Pro 2.1 and Python 3.6.2. and I am writing a script that involves the arcpy.ListUsers() function and whenever I run the code I receive the following error: The SDE workspace ...
-3
votes
1answer
38 views

How does someone write a python function? [closed]

How does someone write a python function that converts a 'date' to the day of the year (e.g. Jan 31st would be the 'date' and 31 would be the day of year, Feb 1st would be the 'date' and 32 would be ...
2
votes
2answers
105 views

Adding xy data and exporting layer in function using ArcPy?

I am trying to add xy data into the attribute tables of 2 point layers, then export the tables into 2 separate excel tables using this code: env.workspace = r"G:\PROJECTS\osfie\gis\lyr" lyr1 = r"G:\...