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
1
vote
1answer
267 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
57 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
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 ...
3
votes
1answer
110 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
107 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
138 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
54 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
312 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
114 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
139 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 ...
0
votes
0answers
213 views

Connect to local file or PostGIS layer in field calculator QGIS

I'm trying to make query from field calculator so that it would be possible to connect to PostGIS layer (or local file on computer) and select data according to condition so that use this selection ...
0
votes
1answer
812 views

Use a sde.st_geometry function in a PL/SQL trigger

I have a PL/SQL trigger: 1 create or replace trigger "projects_to_meas_trig" before update of asset_id 2 on projects 3 4 for each row 5 declare 6 v_length number; 7 begin 8 ...
0
votes
0answers
187 views

Calling a function for two geojson files in Leaflet

I have two geojson files : 1- world_countries.geojson : each feature has properties "name" and "relation" as in the following example: { "type": "FeatureCollection", "features": [ { "...
1
vote
1answer
1k views

Removing n first digits on a field attribute table using QGIS string functions

I'm looking for a QGIS function to remove the first n digits on a field attribute table using QGIS string function. For exemple I have the following string in a QGIS attribute table: 742-004-SRV ...
1
vote
0answers
290 views

QGIS auto fill with increments

i want a shapefile table to be autofilled,for example each new point i place has an attribute column that auto fills its self a set of repeated numbers such as (1,2,3,4,1,2,3,4,1,...etc) and another ...
1
vote
0answers
152 views

QGIS referring to a features length with python in function editor

I tried to modify the code given in https://gis.stackexchange.com/a/212762/7849 so the value from [field_name] would be divided by the length of the feature. I tried to change the last line in ...
2
votes
0answers
48 views

Populate b.field into a.field when 2 vector points not always coincident but should be coincident

Using QGIS/pgAdmin3, I have a situation where two vector points, should be coincident but I can't guarantee they always are, I need to take feature a.field and populate a field in feature b, upon both ...
2
votes
0answers
31 views

How to obtain Wide Function in QGIS?

Is there a way to compute the wide function in QGIS?. I want to obtain this function to compare the topology of two stream networks. According to Bras (1990) the wide geometrical function N(x) ...
5
votes
1answer
411 views

Writing QGIS field calculator formula?

I have a table with 2 fields, field1 contains site specific data, field2 contains a number which groups the field1: Field1, Field2 180, 1 203, 1 220, 1 205, 1 160, 2 140, 2 135, 2 I want to sort ...
2
votes
0answers
293 views

Splitting / Divide Polygon in same squares

I have a polygon in a table with 100 meters to 100 meters ( 1 row) and I would like to splitt / devide it to same square parts for 10 meters. The result should be then 100 rows with 10x10 meters. How ...
3
votes
1answer
391 views

Accessing each value from array and feed it to another function in PostGIS?

I have an edge_table containing start_id and start_geom column. I want to make one function which will take integer array as input (starts). In between the function, the array values will be checked ...
1
vote
1answer
2k views

R - aggregate with additional argument

I would like to use the function aggregate (R raster package) to assign to a grid point of the new raster the number of grid points of the old raster that have a certain value for(val in 1:10) { ...
1
vote
0answers
147 views

Crop a raster by a grid shapefile with different extensions in R

I need crop a raster by a grid shapefile to obtain raster files cutted according to grid cells (which are named "PageNumber"). My function is: g=shapefile("50x50km_final.shp") f=raster("...
1
vote
1answer
108 views

How to get next/previous layer in leaflet?

I want to create buttons to get next/previous layer but i don't know how to build code to make it possible. var bounds = [[0,0], [2048,2048]]; var floor0 = L.imageOverlay('img/Floor-00-map.png', ...
1
vote
1answer
93 views

GeoNode use other language then selected as default (english as default would be great)

In GeoNode you can select the language in which you want to display the portal. Default is English, sometimes it uses automatically German, French...does this depend on the Windows language/ region ...
1
vote
2answers
452 views

Find layerattribute at certain point

I am trying to find the closest road segment to a point that I have and return an attribute from the closest segment to the given points. How should I do that? Any suggestions? Can i use a marker and ...
5
votes
1answer
961 views

referencing to features geometry in an expression

I have a layerA with roads and a layerB with one shortest path. If I put an aggregate function into a virtual field in layerB to calculate the sum of fieldAA where the shortest path contains features ...
2
votes
1answer
124 views

Linking layers using conditional spatial queries?

I am looking at a drainage scheme where there are blockages in the system. The blockages are one layer. I then have a layer containing the main risk areas within the area and another layer that ...
1
vote
1answer
34 views

Highlighting features that contain data only

I am trying to highlight individual features in a grid that contain Jobs data from an $.ajax call. I already have a highlight function that highlights the grid cells when they are moused over and I ...
2
votes
1answer
2k views

Getting multiple functions to work with mouseover event in Leaflet

I am making a web mapping app using leaflet and some geoJSON data for a grid. I want to be able to mouseover each grid cell and both highlight that cell AND show a popup of the coordinates. In the ...
1
vote
1answer
362 views

Problem with QgsMapCanvas().zoomToSelection() when running from function

I have the following function which, when typed in to the python console line for line works fine, but when I use the function it gets as far as highlighting/selecting the accident (feature) but the ...
3
votes
2answers
3k views

How to extract part of string after '*', '~', '-' or '#'

I have strings like this: 234/1-1 3345#5 11/2~10 6754*15 It needed only rightmost part of string after '-', '#', '~'or '*' . I figured how to extract when there is only one sign for example '~' ...
1
vote
1answer
257 views

Why are there my_form_open() Python functions in my QGIS project file?

I have a project open with 6 layers (MapInfo .tab format), have set the style for each layer and added labels for 1 of them. So for a simple project the .qgs file is about 2000 lines long and among ...
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 ...
2
votes
1answer
1k views

Arcpy module to read csv files and create polyline shapefiles

I am creating a module in arcpy that will loop through a folder with csv files in it. I have both of them written, and they work fine on my computer. However when I send them to anyone else they won't ...
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 ...
-1
votes
1answer
152 views

Trying to use functions [closed]

Trying to use functions. First, embed the code in script, then I'll trying calling them from a file. I'm getting the error denoted below. After two days, it's time to get some fresh eyes ... Python 2....
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
0answers
121 views

A mesh points for each polygon: how to create function?

I want to use function for creating a mesh point for each polygon, but I am new in python. what is wrong with the function: def creatingPoints(minX, minY,maxX,maxY,number): while minY < maxY: ...
6
votes
1answer
172 views

Why do I need to use labelling when setting fill colour with a python expression in QGIS?

I'm having problems using a Python function in the expression editor to style a polygon fill in QGIS. I'm trying to use a random colour scheme. However, I need to do this over a series of different ...
6
votes
2answers
1k views

QGIS Field Calculator functions

Using QGIS 2.12.3, within the Field Calculator "Geometry" section, there are certain functions, such as "area", that also have a corresponding term beginning with a dollar sign, i.e. "$area". I don't ...
1
vote
1answer
1k views

Leaflet: Change icon inside a function

I have a custom function that pulls the markers from a json file called markers.json : var markers = { "resources": [ { "name": "AITokarServer", "coords": [ { "x": ...
1
vote
1answer
888 views

Nearest Neighbour function

I'm trying to create a function which calculates the nearest neighbors under a certain length in a table s_1 an stores them in an output table. This is what I've got so far: CREATE OR REPLACE ...
3
votes
2answers
248 views

ST_Distance loop

I want to create a postgresql function which calculates the distances between random points who are stored in one table. For the Table: CREATE TABLE s_1( id bigserial primary key, the_geom geometry, ...
2
votes
1answer
480 views

QGIS polyline length calculation [closed]

I meet a problem while I try to calculate the length of a polyline in QGIS in the attribute table. I created a new column with the function "$length" inside (type: real, 10 digits and 3 digits of ...
0
votes
1answer
556 views

function in update cursor

I have az update cursor loop, in which I'd like to use the function written earlier. Function: def TL (): addlayer = arcpy.mapping.Layer(r"gk25.shp") arcpy.mapping.AddLayer(df, addlayer, "...
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 ...
1
vote
2answers
93 views

Function for hyperspectral rasters with 3 variables unexpected error

I am writing a script to extract vegetation indices from hyperspectral datacubes. One of the indices is the Triangular Vegetation Index for which I wrote the following function: TVI2 <- ...
1
vote
0answers
51 views

Which are the steps the union functon goes through? [closed]

While skimming the union function I could see it works with intersecting bounding boxes, layer features and attributes. But how, exactly does this function work; which are the lines that check for ...