Tag Info

Hot answers tagged

13

If the length of the ID field values is always constant I would recommend using either Field Calculator or Calculate Fields tool with python slices. TOWN calculation: !ID![:8] ERF calculation !ID![8:16] PORTION calculation !ID![-5:]


5

Install the XY Tools plugin by Richard Duivenvoorde. Select a vector file from the ToC (that is, make it active). Go to Vector->XY tools->Save attribute table as Excel file. You would need the Python library xlw installed for doing so.


4

You can copy the following script to your QGIS (Processing Toolbox > Scripts > Tools > Create new script). This script takes shapefiles from one folder, uses the Field Calculator algorithm to add the filename as an attribute (with Null values but you can edit this to another expression) and outputs the shapefiles into another folder: ##Test=name import os ...


3

You need to pass the returned value in a variable, not reference the column itself. Expression: result Codeblock: if [ColumnB] > 0 then result = [ColumnA] / [ColumnB] else result = 0 end if Here's how the two parts fit together in the field calculator - my data doesn't have the same field names, but you get the idea.


3

The problem was that both the current working copy and the shadow copy tables were named the same. The join went fine but the field calculator and geometry were greyed out. To fix this, I simply renamed the backup table name to something different. I was able to field calculate and essentially restore the data. I did not find this resolution documented ...


3

Building on @artwork21's excellent answer, the following is how you would accomplish the task with Python using an UpdateCursor. import arcpy # The input feature class fc = r'C:\temp\myfgdb.gdb\yourFC' # Add three new fields arcpy.AddField_management(fc, "TOWN", "TEXT") arcpy.AddField_management(fc, "ERF", "TEXT") arcpy.AddField_management(fc, "PORTION", ...


2

How about using this in the 2.2 Field Calculator? Long field = substr(geomToWKT( centroid( $geometry )), 7, 12) Lat field = substr(geomToWKT( centroid( $geometry )), strpos(geomToWKT( centroid( $geometry )), ' ')+2, 12) Seems this is addressed in 2.6 with the xmin option xmin(centroid( $geometry ))


2

To get a csv file of the attribute table, rightclick on the layer in the legend, and change the file format from shapefile to CSV. You might need to change the separator from comma to semicolon in a text editor if Excel does not like the default separator.


2

Extracting coordinates of start/end vertices (not all line vertices) from lines is a nice use case for new functionality in QGIS v.2.8, namely, the function editor. This is the workflow: Load your line layer to QGIS and activate it. Open the field calculator and go to tab Function Editor. Click on New file, write vertices as the new file name, and click ...


2

Click on Vector -> Geometry Tools -> Extract Nodes A window will appears, choose a file to save and mark the option "Add result to canvas". Right click in the new layer created and click on "save as". Choose a name to your file and open it with a text editor to check the result.


2

For exporting the coordinates too, I assume you will have to add new columns for x and y coordinates and calculate these using the fieldcalculator with the appropriate operators.


2

Export table to excel: Right click layer in table of contents select Save As Under Format drop down select Comma Separated Value (CSV) option Open excel and browse for saved .csv to open


2

This use case should be covered by the Relations feature: see User Manual - Creating one to many relations or Matthias Kuhn's QGIS Relations post.


1

I have found a solution to my issue and I would like to share it. I managed to export attributes (up to two) in the "save as" window when saving a vector layer. More precisely, in the "data source options" section, I have: Set as "relativeToGround" the "Altitude Mode" Wrote name of attribute I would like to export in the "DescriptionField" field Wrote ...


1

The kml xml schema does not have a tag for labeling polygon features only placemarks = points. A workaround for doing this is to create a new point layer from polygon layer and in the Save vector layer as dialog define the labeling field in the NameField text box. Once you have both kml creted in GE, select File>Open to add both kml in. Alternatively, you ...


1

1) Click in Vector --> Geometry Tools --> Extract nodes 2) In the new window a)check "Add result to canvas" b)Browse your locate and save with a name 3) Whait a moment, in the layer Right click and choose "Save as" 4) In "Format" choose the "Comma Separated Values (.csv)" 5) And open the .csv file in to Excel and you have all ...


1

You can use this code in field calculator to increment by 1. Parser: Python Expression: autoIncrement() Code Block: rec=0 def autoIncrement(): global rec pStart = 1 #adjust start value, if req'd pInterval = 1 #adjust interval value, if req'd if (rec == 0): rec = pStart else: rec = rec + pInterval return rec


1

Sorry for that stupid question! I did find an very easy way to do what I aked in this thread. Just use the QGis processing tool and the SAGA "merge vector layers" tool. The merged shape file has a column (called "Layer") filled with the shape file names.


1

From your comment I would assume that you just want to add a new field? Open the attribute table of the file, start an edit session, and then use this button: In your case you would have to opt for Text:


1

give this a run. it should give an attribute called "number" and start from 0. import arcpy from arcpy import env import os import time arcpy.env.overwriteOutput = True y = #Your folder that contains all of the subfolders def main(x): try: import arcpy, sys, traceback, os, glob, shutil arcpy.env.overwriteOutput = True ...


1

I wrote this a while back and is should get you close. what this will do is step through all of the folders in a root folder, find the shape files, add an attribute called "shpname" and popuplate it with the path to that shape. you can modify it to just toss in the fc name instead of the path. then when you go to merge all of your shapefiles will have an ...


1

You can do this using arcpy in conjunction with numpy: import arcpy import numpy as np input = "c:/data/usa.gdb/USA/counties" arr = arcpy.da.FeatureClassToNumPyArray(input, ('population_density')) ##to create 3 rank for example p1 = np.percentile(arr, 33) # rank = 0 p2 = np.percentile(arr, 67) # rank = 1 p3 = np.percentile(arr, 100) # rank = 2 #use ...



Only top voted, non community-wiki answers of a minimum length are eligible