The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
2
votes
1answer
51 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
0answers
27 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
148 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"...
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
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
70 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. # ...
3
votes
2answers
9k views

Leaflet layers on different zoom levels. How?

I've added a polygon layer and a point layer to my leaflet map. I would like the points to appear after a certain zoom level or when a "click" event occurs e.g. (polygons.on("click", function....) ...
1
vote
1answer
14k views

Python: Point in polygon, boundary and vertex check (ray casting)

So I have written some code to check whether a point [(x,y)] lies within a polygon [(x,y), (x,y), (x,y), (x,y)] but the code fails if the point lies on a boundary or a vertex, I need this to be ...
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.
0
votes
1answer
56 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 ...
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
360 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
57 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 ...
4
votes
1answer
370 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
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
32 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
104 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
92 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
89 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
160 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
2answers
426 views

QGIS stopEditing function in python

I am trying to stop the edits using the python console of the QGIS and the code QgsTrackedVectorLayerTools.stopEditing(layer,False) where layer is the layer in the edit mode. I am receiving the ...
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
556 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
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:\...
2
votes
1answer
55 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 ...
0
votes
2answers
256 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 ...
2
votes
1answer
470 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] ...
1
vote
1answer
171 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)....
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 ...
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 ...
2
votes
0answers
178 views

Application of a Piecewise Logistic Function to Extract Seasonality Metrics

I am working with 16-day MODIS EVI (satellite) data and I want to fit a Piecewise Logistic Function through my 23 EVI data values. The following formula is for the Piecewise Logistic Function: y(t)= [...
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 =...
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 ...
1
vote
1answer
111 views

CartoDB adjusting the style of the layer toggle function

The layer names are cut off in the toggle layer function. Is it possible to adjsut the font size or the length of the layer function box so text is not cut off?
5
votes
1answer
841 views

Specifying input layer in custom QGIS function to rank features

How do I specify the input layer so it refers to the layer from which the function was called (without having to explicitly identify it by name)? I have written a custom function to use in the ...
4
votes
2answers
5k views

QGIS Error while executing Python function in openProject() Macro: “QgsMapLayerRegistry is not defined”

I have the following script that sets the a feature id automatically after a new feature is digitized. I want the following function to be executed automatically when project is opened (and layers ...
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
236 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 $...