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
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
175 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
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
554 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
362 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 ...
1
vote
2answers
97 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
160 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("...
2
votes
1answer
250 views

Calculate mean for a each object of SpatialPointsDataFrame

I have a list with several SpatialPointsDataFrame objects, and each object has certain slots. How can I calculate the mean value of a certain slot for every object in the list, and then save that ...
1
vote
2answers
2k views

Can TextSymbolizer font size be set as a function of the scale?

The standard behaviour when rendering WMS layers is to keep the text size across all scales and then filter out colliding labels so that the text remains readable, although delivering incomplete ...
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 ...
2
votes
1answer
921 views

Selecting entities based on first character of field being a letter using QGIS?

I would like to select entities whose addresses are incomplete, i.e. the first character is a letter instead of being a number. Does QGIS have an "is numeric" -type function to accomplish this? Not ...
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
429 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 '~' ...
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 ...
3
votes
1answer
552 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 ...
-1
votes
1answer
203 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....
1
vote
0answers
133 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: ...
1
vote
1answer
2k 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": ...
2
votes
1answer
964 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
338 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, ...
0
votes
1answer
638 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
150 views

How do I get the distances to every cell in GRASS?

I have an elevation raster map, a point, a raster map defining the viewshed from that point, and now I want to produce another raster map with the results of a function of the distance between the ...
4
votes
1answer
1k views

Reading and plotting shapefiles with a custom function in R?

I have this piece of code that want to turn into a function r <- readShapeSpatial("roads") b <- readShapeSpatial("buildings") lc <- readShapeSpatial("landcover.shp") here is the preparation ...
3
votes
1answer
13k views

Save raster to file when using stack() in R

I'm working on a function for raster package. In the end of the function I have to use stack() to create a RasterStack. When I do this the data source is in memory. I want to have the data source on ...
1
vote
0answers
181 views

How to fill a symbolLayer with a custom texture?

I have this code : pLayer is a QgsVectorLayer * QgsFeatureRendererV2 * lrenderer = pLayer->rendererV2(); QList<QgsSymbolV2 *> lSymbols = lrenderer->symbols(); QgsSymbolLayerV2 * ...
0
votes
0answers
391 views

Problem in running r.slope.aspect in GRASS

I am new to GRASS GIS, and have been trying to use the r.slope.aspect function to find out the slope, dx and dy rater map from an elevation map(512*512)[1]. But I am getting the following output: ||...
0
votes
1answer
469 views

Using Python function in ArcPy script?

I have an script to transform DN into Reflectance of each band of several images. The unique variable of the equation, apart of the Band itself, is the Divisor: (B1 - 1) / 508 (B2 - 1) / 254 (B3 - ...
0
votes
1answer
114 views

Loop through table, look for word in text field, set boolean true if word exists

I want to create a function that loops through a table and checks if a specific word exists in a text field. If it does, the function should set a Boolean field true. This is what I've come up with. I ...

1 2 3
4