Stack Exchange Network

Stack Exchange network consists of 175 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 [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.

0
votes
0answers
16 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:...
0
votes
0answers
30 views

Iterate same code [on hold]

I tried to execute code in a specific region. I want to iterate this code to a different region but the result obtained from the previous (layer) one should be combined with the next result. For an ...
1
vote
0answers
37 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
33 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
105 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
21 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
41 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
28 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
29 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
75 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
76 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
54 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 ...
0
votes
1answer
46 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
47 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
29 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
123 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 ...
3
votes
1answer
191 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
245 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 = ...
1
vote
1answer
33 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
220 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
159 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
46 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
37 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
45 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
961 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
260 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
147 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
55 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
149 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
238 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
25 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
167 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
88 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
157 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
96 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:\...
1
vote
0answers
108 views

Converting @layer_name tokens into Shapefile Attributes (Columns/Rows) using QGIS Expression Editor?

I'm a fairly novice Python user and I've been banging my head against this problem for a number of days now. Assumptions I've made: This is doable within QGIS, and does not need to be done ...
2
votes
1answer
334 views

Reusing leaflet map elements in custom functions in Shiny/R

I have an application that reuses several leaflet elements, so I'm trying to build functions to streamline my code. All of my logical attempts failed, so I utilized an example I was familiar with ...
1
vote
1answer
217 views

Calculating albedo values with landsat 7 ImageCollection/FeatureCollection error in Google Earth Engine?

I am facing a technical difficulty with Google Earth Engine I am trying to retrieve the albedo value of the state of Idaho by using Landsat7 TOA reflectance imagery over the span of a year. ('2005-01-...
5
votes
1answer
1k views

Style line-width proportionally to maintain relative size in Mapbox GL

I want a data driven line-width to keep its relative size in all sizes I tried using an exponential function for that but it did not work the way I expected. For the sake of the example let's say I ...
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 (...
4
votes
2answers
330 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 ...
3
votes
1answer
103 views

PostGIS function testing geometries, inside and boundary

Is there a st_????(A geometry, B geometry) in PostGIS that returns true when B is inside A and possibly shares a boundary ? I would say no after reading the doc but something may have escaped me.
1
vote
0answers
94 views

How to call a stored pgsql function from Geoserver?

I created a stored function in PostgreSQL : myfunction(a text, b integer). I want to create an SQL View in Geoserver using this query : Select * from myfunction('%nom%', %likes%). My problem is that ...
1
vote
1answer
125 views

Counting average of all polygons instead of every polygon in PostGIS?

I'm facing a problem with counting avg of all polygons in pgsql query. Instead of that I receive avg(of an area) of every polygon separately. My syntax is looking like this: CREATE OR REPLACE ...
1
vote
0answers
51 views

Using Python function for cost calculation in GIS

I want to calculate the cost of two raster layers (ramdom, simulated) composed of values 1 and two, the first created randomly and the second by optimization using two associated cost layers. The code ...
4
votes
2answers
273 views

How is the st_length function stored in an Oracle geodatabase?

How is the st_length function stored in an Oracle geodatabase? Is it in a: PL/SQL function Separate .dll library Somewhere else? I've noticed that the sde.st_length function works, even when the ...
-1
votes
1answer
100 views

How add GRASS functions to QGIS 2.6? [duplicate]

In my toolbox doesn't exist any grass function, what act I should do?
0
votes
1answer
111 views

How to install QGIS 2.6 with GRASS functions?

I install QGIS 2.6 but QGIS-OSGeo4w didn't install GRASS functions. I removed other versions from control panel (feature and program) but, in all of times that I install it, I confront with this error ...