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
11
votes
3answers
7k views

Extracting part of string from field 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( ...
0
votes
1answer
912 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
319 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 one ...
0
votes
1answer
72 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
970 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
383 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
32 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
238 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
173 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
614 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
39 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
150 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
176 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 ...
3
votes
1answer
716 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
539 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-...
6
votes
2answers
3k 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
373 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
877 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
120 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
155 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
240 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
58 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
496 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
146 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
211 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
277 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
1k 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
216 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": [ { "...
2
votes
1answer
4k 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
365 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
173 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
51 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
550 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
360 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
516 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
3k 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
158 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
199 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
126 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
512 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
1k 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
149 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
38 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
3k 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 ...
2
votes
1answer
424 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 ...
6
votes
2answers
5k 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
368 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 ...
7
votes
2answers
7k 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
2k 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 ...