Tag Info

New answers tagged

1

According to this tutorial the map function returns a list: >>> items = [1, 2, 3, 4, 5] >>> >>> def sqr(x): return x ** 2 >>> list(map(sqr, items)) [1, 4, 9, 16, 25] >>> So your code should be something like this: def Distance(Latitude, Latitude2, Longitude, Longitude2) pList = map(math.radians, ...


0

I believe your expression should be: left( "SITE_ADDR", strpos( "SITE_ADDR", ' ' )) Note single quotes around string, do not need to minus 1.


2

Use the substr function under String list for example: substr( 'L3NAM1988K', 6, 4 )


2

The simple answer might be that changes to your polygon layer will not be confirmed until you save our edits. Make sure you save your edits between creating your ring and doing your area calculation. I believe it is possible to create automatically updating area fields in QGIS 2.4, but I haven't been able to do it myself as it requires a bit of Python. ...


1

I'm not sure where %Name% is coming from, so I may not be able to answer your question entirely, but wrapping something in exclamation points is how you get a value out a field in a python code block. %Name% is a model builder variable, not a field name. So remove the the exclamation points and just use %Name%[3:] and see if that works.


2

I noticed a few irregularities in your example: 1) your date field is actually a text field and 2) your math does not seem to be correct. The following approach should work for you: In the Pre-Logic Script Code def correctDate(x,y): if x == "delivery": newValue = str(int(y.split("/")[0]) + 4) a = newValue + "/" + y.split("/")[1] + "/" + ...


1

You need to construct your string properly. Instead of: 'POINT("shot.lon" "shot.lat")' Try: 'POINT(' + "shot.lon" + ' ' + "shot.lat" +')' EDIT - However - for your example, that will only give you distance in degrees. This will work for projected coordinates (UTM, for example) but not decimal degrees.


3

The general terrain attribute that you are describing is called Relative Aspect (RA) and in its general form, it can be calculated for any input azimuth (Az) as follows: RA = Abs(aspect - Az) if (RA > 180) { RA = 360 - RA } where aspect is the terrain slope aspect calculated from the DEM. Here is an example of code that calculates the index ...


4

And...if you want to use VB, you simply add an " & " between your folder location and your existing photo ID: "Your folder location" & [Existing ID]


5

Using the Python parser, you can combine text using +. For example: "C:/this/is/a/test/" + !FileName!


3

Your expression looks incomplete but I am assuming that the first part of it is trying to find the square of the cube root. My test below on that when R had a value of 8 returned the expected value of 4 to the RESULT field RESULT = [R] ^ ( 2 / 3 ) The above worked when the parser is set to VBScript. With Python, there is hopefully an easier way but I ...


2

The problem is in your code block. Instead of: def Reclass( !CODE! , !COMPLEX! ): if ( !CODE! == 1.1.7 and !COMPLEX! == 4): return 1.3 elif ( !CODE! == 3.2.0 and !COMPLEX! == 4): return 1.3 else: return 0 try: def Reclass( CODE , COMPLEX ): if ( CODE == "1.1.7" and COMPLEX == 4): return 1.3 elif ( ...


1

Well, with the help of a friend I got the code to work. Here's what it looked like in the end: def percvr(sp1,per1,sp2,per2,sp3,per3,sp4,per4,sp5,per5): sum = 0 if (sp1 == "Sw" or sp1== "Se" or sp1== "Sb" or sp1== "P" or sp1== "Pl" or sp1== "Pj" or sp1== "Pa" or sp1== "Pf" or sp1== "Fb" or sp1== "Fa" or sp1== "Fd"): sum=sum+per1 if (sp2 == "Sw" ...


1

You could try normalizing the table. Basically, you create a separate table with ForestCoverID, Species, and SpeciesPercent columns where ForestCoverID is the key to link back to the individual polygons. Each ForestCover polygon will then have up to 5 rows in the table, though, likely less as you don't need to record the 0s. Then you only need to query ...


0

Use 2 lists as function arguments def percvr(listOfSp,listOfPerc): conif,sum=('Sw,"Se'..),0 for sp in listOfSp: if sp in ('Sw',"Se'..): i=listOfSp.index(sp) sum+=listOfPerc[i]


2

Taking account of the comments by @nmpeterson and myself against your question, I would try the following: Pre-logic Script Code: def a(Riesgo,Direccion): if (Riesgo == "Alto" and Direccion == "Sur"): return "Sur" Mensaje = a(!Riesgo!,!Dirección!)


1

So, for the first python script for QGIS, I have: from qgis.core import * from PyQt4.QtCore import * from PyQt4 import QtGui, QtCore import math COMP = 1.0 FACS = 0.0 ORIG = 1.0 OROM = 1.0 ORZE = 1.0 coeff_a = 1.6 coeff_b = 3 seuil_1 = 1000000 seuil_2 = 300000000 # supply path to where is your qgis installed ...


0

If I understand correctly you want to divide, or at least classify, the track into legs. You've got a couple of issues to face, and this probably can't be solved with a simple field calculation. If the GPS data has a single coordinate for a stop, then you'd create a variable called count, then start at the first point and iterate through each following ...


2

You can use a regex replace for this: regexp_replace('0160011000', '0+([1-9]+)0+([1-9]+)0+', '\\1-\\2') regexp_replace("MAP_PAR_ID", '0+([1-9]+)0+([1-9]+)0+', '\\1-\\2') The regex is broken down like this: 0+ - Any number of zeros at the start ([1-9]+) - Any number of values between 1 and 9. Capture into group 1 0+ - Any number of zeros in the middle ...


3

From ESRI Support HowTo: Create sequential numbers in a field using Python in the Field Calculator


2

You can also append text or put spaces between using alternate quotations: "Streetnum" || ' ' || "Streetname"


4

You can use Summary Statistics (Analysis) using the COUNT option on your field, then from that, you can see which repeat "more than 20 times" or however many times.


3

in the code block you'll define a function, and then in the expression, you'll call the function with the needed field names, like so : Code block : def picture_name(current_name, map_number): return current_name[current_name.rindex("\\"):] + "|" + map_number + ".tif" Expression : picture_name(!Pictures!, !MapNumber!) I haven't test this code, ...


3

Pieside's answer gives you the straightforward way of doing it. An alternative you may wish to consider is to use the 'Statistics by categories' tool in the Processing toolbox (just open the Processing toolbox and type statistics in the search bar and you'll find it. This tool creates a table of basic statistics (min. mean, max, stdev, count) in one field ...


2

In the menu, click on Vector->Analysis Tools->Basics statistics. See the end of: http://www.qgistutorials.com/en/docs/calculating_line_lengths.html.



Top 50 recent answers are included