Questions tagged [syntax]

the structure of statements in a computer language.

Filter by
Sorted by
Tagged with
1
vote
1answer
22 views

Cleaning SQL queries [closed]

I have a bit of SQL code that look similar to this: SELECT sum(case when latitude = '0' then 1 else 0 end) as count_zero, sum(case when latitude is NULL then 1 else 0 end) as count_null, sum((case ...
2
votes
1answer
30 views

Creating a table view using SQL?

I'm trying to create a table view using SQL to join a table and a feature class together. When I try to create the view, I get an error saying there is an incorrect syntax near the keyword 'CREATE'. I'...
1
vote
1answer
82 views

PostGIS-syntax: export query-result to QGIS / Shapefile

Using PostGIS: syntax-basics for function, I was able to solve a long-standing problem by creating a geometry, using a SQL-query with PostGIS. However, I want to use the created geometry in QGIS and ...
1
vote
1answer
80 views

Raster calculator - problems with syntax

I have a raster layer with values ranging from 0.00597303 to 0.102894 and I want to assign specific number representing a group to specific range of values: Group 4: x >= 0.1 Group 3: 0.01 <= x ...
4
votes
2answers
77 views

Adjusting condition in field calculator in QGIS [duplicate]

I need to calculate a score based on an area field using these ranges: if >= 30000 (square meters) then 4 (score) if < 30000 AND >= 10000 then 3 if < 10000 AND >= 5000 then 1 if &...
1
vote
1answer
175 views

Raster calculator issue in QGIS 3.8 and 3.8.1

I am trying to perform a simple raster calculation on an elevation layer to occlude certain values. I have used the following expression: ( ( "clipped_elev@1">500) AND ("clipped_elev@1"<1000))*"...
2
votes
1answer
46 views

Query land use (Raster calculator)

I have a land use raster file and am trying to use the raster calculator to query the file for surface water. The saga formula (11 = surface water band): (a, 11) This does not work. Can anyone ...
7
votes
3answers
1k views

Difference between quotation marks ('single' vs “double”) in QGIS

I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double"). I know something about the quotation marks and the way they are applied in Python ...
1
vote
1answer
38 views

Syntax for if clause with an inline variable in modelbuilder

In the "Calculate Value" tool I am trying to slice the inline variable (%Name%) with another variable (A) that will be a result of the length of the %Name% variable. For example if %Name% = 11 then I ...
0
votes
1answer
31 views

Calculate conditional in line feature using an expression

I'm trying to calculate a conditional in a line feature but I can't see were my sintax is wrong. Could you guys help me? def Reclass(TIPO_PAV): if TIPO_PAV=='TERRA': return !shape.length@...
4
votes
2answers
163 views

How do I convert a string into a column number in QGIS Expression Builder?

I want to highlight parts of a map based on the page number in an atlas. Ideally I'd use the expression builder in the layer style menu to set the Column to equal the atlas page number. My expression ...
3
votes
1answer
77 views

Select By attribute - top 100 values for each district

I am trying to determine the highest 100 values for each district in a shapefile. I have 27 unique districts and 62834 records, but not sure how to proceed. I could "split by attribute" based on the ...
0
votes
1answer
81 views

ArcGIS Pro Script Tool Syntax Error

I'm trying to learn how to create Script Tools in ArcGIS Pro, so I thought I would start small with a tutorial on https://www.e-education.psu.edu/geog485/node/120 The tutorial has you make a simple ...
4
votes
2answers
480 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 ...
1
vote
1answer
58 views

If Statement Satisfied but not Entering?

I have some code that seems to behave as expected and occasionally satisfies an if loop I've created but the code never seems to enter the loop. Even where the if statement is satisfied. The 'Warning'...
0
votes
0answers
88 views

Python script from Python Toolbox do not work and show no error

I have a Python ToolBox with two Custom Python Scripts. The first one works well, but when I try to run the second, there is no errors, but the operation do not run. import arcpy class Toolbox(...
4
votes
3answers
244 views

QGIS query/syntax for overlapping features

I have a dataset (buildings, polygons) that has some overlapping features. Some buildings are old and already demolished but are still in the dataset. I want to hide all these. These have properties ...
1
vote
0answers
118 views

Merge Symmetrical Difference and Intersection Line

I tried to merge these two types of lines I have from using the geometric tools "Intersection & Symmetrical difference". They end up being part of the same line and I want to join them together ...
2
votes
0answers
111 views

Zoom to Postcode QGIS Plugin error: “”

When trying to use the ZoomToPostcode plugin in QGIS 2.16.2 Nødebo, after inputting a postcode to jump to I am prompted to download updated postcode files. Clicking Yes generates a "Unable to download ...
2
votes
2answers
5k views

PostGIS: Update table with st_geometryfromtext [duplicate]

I'm trying to update a column wkb_geometry in a table locations by creating a point from the eastings and northings cols from the same table. The database is PostGreSQL with PostGIS extension: UPDATE ...
3
votes
2answers
224 views

ogr2ogr sql - how to call file from a variable set in a loop in windows batch

I have a command ogr2ogr -f sqlite -dsco SPATIALITE=YES " !outfile!.sqlite !infile1! -nln !outfile! -dialect sqlite -sql "SELECT ST_Intersection(A.geometry, B.geometry) AS geometry, A.name, B.name ...
1
vote
0answers
107 views

Calculation appropriate angular step depth in depthmapX

I am a new depthmapX user in which trying to calculate segment step depth from specific segment to store cumulative angles for each segment. Is there anyone who can provide advice to implement it? ...
2
votes
2answers
1k views

Copying some entries from one column to another with QGIS field calculator? [closed]

I have some rows in the AttributeTable where I want to copy some entries from one column to another. I thought that the best way to do this was in the field calculator and use a CASE WHEN expression ...
3
votes
2answers
2k views

Checking if optional parameter/field has been used or not in ArcPy?

I have 6 arcpy.GetParameterAsText The first one is a feature class and the remaining 5 are fields (some being optional). I plan to use an if statement to check if any fields have been selected for ...
2
votes
1answer
1k views

Arcpy.Intersect_analysis problem

I am very new to Python, after using ArcGIS for a few years (Toolbox only). I thought I'd get stuck in and try and pick it up as I went along, but I've come to a stumbling block with ...
1
vote
2answers
257 views

SelectLayerByAttribute() got an unexpected keyword argument

I am trying to update a field with a new value as I updated a Domain for a web purpose. I am new to this. I want be able to choose the layer and then the field to update M=Municipal S=State C=...
0
votes
1answer
113 views

Error in Raster Calculator when copying syntax typed in text editor

I have a very long operation string using conditionals and simple operations. However, I get an error when copying the syntax to Raster Calculator, apparently the commands are not recognized when ...
-1
votes
1answer
58 views

python script sytax error [closed]

I keep getting this syntax error and don't know why. Brand new to python. # Opens a feature class from a geodatabase and prints the spatial reference   import arcpy   featureClass = "C:/Users/Travis ...
2
votes
1answer
112 views

QGIS Marker Expressions

I am working on writing basic expressions to control the Marker Properties. My previous question on the syntax for color was graciously answered , but I soon realized that I need to know the syntax ...
0
votes
1answer
674 views

Writing expression for field calculator in Python?

I have a script where I calculate a couple of variables, add a new field then need to do a field calculation that field. Once I get everything set up, it's the expression that I have a hard time ...
2
votes
1answer
7k views

How can I make buffer with ST_Buffer in PostGIS

I am trying to make a buffer(0) as a fix-geometry process in PostGIS 2.2.2. It like this: SELECT ST_Buffer(ST_GeomFromText('POINT(100 90)'),0,4); I am using sources from this man-page. It ...
1
vote
1answer
110 views

Assign row object as field name in ArcGIS

Is there a specific way to assign the object that for example row[0] returns in a SearchCursor to a new field name? I mean how to write it in add field syntax, this doesn't work: arcpy....
2
votes
1answer
476 views

SyntaxError with custom function using QgsFeatureRequest.setFilterExpression

def get_subsel(layer,filter): layers = iface.mapCanvas().layers() for lyr in layers: if lyr.name() == layer: request = QgsFeatureRequest().setFilterExpression(filter) ...
1
vote
3answers
423 views

Using if else syntax in field calculator with Python?

I want to calculate a field in the field calculator that are dependent on the values in 4 other columns. My columns are "A", "B", "C" and "D" Now I want to fill the column "X" with: if "A" and "B" ...
3
votes
0answers
101 views

VBScript Syntax Error in ArcGIS labeling? [closed]

I have been using a script on older ArcGIS to convert depths in engineering format to the Hydrographic format seen on charts. On trying to use it I get a syntax error in Line 14. No matter how I ...
2
votes
1answer
91 views

ArcGIS Field Editor if/else syntax with python

I am just starting with Python and ArcGIs so here is my question: I have the column "DB_Low" (Type "Long") and want to fill a new column by changing values. The new column will be a Float-Type field. ...
1
vote
1answer
69 views

ArcGIS - if clause in the field editor with python

I have 2 columns in my table. "dB1" and "dB2" Now I want to calculate a third columnn "dB3" depending of the entries in column "dB1" and "dB2" if "dB1" or "dB2" have an entry of "0" I want to ...
3
votes
0answers
185 views

Translating ArcGIS field calculator python expressions in to QGIS field calculator python expression?

I'm transitioning to QGIS from ArcGIS. I'm having trouble getting my python field calculator expressions to work in the QGIS advanced python field calculator. Here is a screenshot of the working ...
1
vote
0answers
58 views

problem with raster calculator syntax [closed]

I am trying to build a raster representing the output from a logistic regression model. i keep getting syntax errors. heres the script: -2.41-(15.97 * "Topographic_Predictors\wadem10m_annsolrad") - (...
3
votes
1answer
609 views

Conditional Statement in QGIS Field Calculator

I'm using QGIS to calculate total loss in an earthquack attack. I wrote this expression in Field Calculator. CASE WHEN "build_type" = 1 AND "MMI" < 5 THEN "perc_loss" = 0 WHEN "build_type"...
2
votes
1answer
398 views

Syntax error in a query with ST_AsText and ST_CENTROID

I have a table in a PostGIS database where with this query : SELECT ST_CENTROID(pol8.geom) AS geom FROM polygon8 AS pol8; I got this: geom -----------...
4
votes
1answer
570 views

QGIS Raster Calculator syntax

I have tried this several different ways and get lots of NaN. I need to specify that in my raster 'test1', I want a certain set of values to equal 1 and the rest to equal zero. For instance, I want 1,...
1
vote
1answer
876 views

Syntax error at or near “1” — PostGIS in Action — Chapter 11 SQL data dump

I'm following along with PostGIS in Action, 2nd ed., chapter 11, while attempting the SQL dump from the data files and I'm getting the following error: ERROR: syntax error at or near "1" LINE 189: 1 ...
1
vote
1answer
610 views

Using decimals in ArcGIS Raster Calculator tool?

I would like to create a new raster by using the following regression equation in the Raster Calculator tool in ArcGIS 10.3: Outputras=0,000826345+(0,000203494*"Roads_density.tif") ("Roads_density....
3
votes
0answers
593 views

QGIS Space Syntax plugin with OSM data?

I'd like to do a space syntax analysis for a city I observe, but when I use the Space Syntax Plugin, the desired shapelayer roads doesn't show up. It's an OSM vector layer, what do I have to do to ...
1
vote
1answer
502 views

Editing values in attribute table column

I have an attribute table with 5,000 records in QGIS. From this I have selected a subsection of 200 records whose attributes I need to modify. In the column called 'NAME' I would like to replace the ...
-1
votes
1answer
915 views

postgis/postgres ST_Distance and GROUP BY

Trying to find the nearest road to a postcode point and order the results by distance. The roads are named according to UK convention so A606 etc and there are multiple entries for many road numbers (...
0
votes
1answer
68 views

Writing code expression in Calculate Value to find cell value or Minimum cell value?

I have a calculate value tool that I'm using to skip rasters without features/no data. I'm very new to python and do not know much about proper formatting and syntax. Right now, the tool works but ...
0
votes
1answer
256 views

mapbasic - how to link my database in my mapbasic coding

I'm creating a tool in MapBasic that identifies the PCI clash in 4G I need help: How do I add database data into MapBasic? How can I calculate mod values and colour the output in MapInfo based on ...
0
votes
1answer
64 views

Calculate field value based on lat long. Have longitude values which are negative?

Very new to python, fairly experienced with ArcMap. I am trying to create an alphanumeric index based on point locations My code string for the numeric part is here: def calc(!LONG_x!): if !...