Hot answers tagged

5

You can use Python and the Field Calculator to strip off the numeric value at the beginning of the string. Select "Python" at the top, and then enter the following in the Code Block: def stripDigit(text): if text.split(' ',1)[0].isdigit(): return text.split(' ',1)[1] else: return text Then, in the bottom-most field, enter the ...


4

What about using re and set and setting a flag ( here 0 and 1) in python- re will extract all the names (last and first) from BENNETT MCCARL & ARNETTE BENNETT without &. For pattern matching re is of highest priority- you can use re how you want. import re def sorter(val): words = re.findall(r'\w+',val) uniques = set(words) if ...


4

You can use the Python collections module and an Update Cursor to accomplish this. This method adds a new field and populates it with a 1 if there are any duplicates, otherwise a 0 if there are no duplicates. import arcpy, collections shp = r'C:\temp\names.shp' # Add a field called "check" to store binary data. arcpy.AddField_management(shp, field_name = ...


3

You can use the Join attributes by location tool. Say you have the following layers: layer_a : the layer to which you want to attach attribute values from layer_b layer_b : the layer from which you want to take attribute values Go to Vector > Data Management Tools > Join Attributes by Location. Then, set the parameters as below: The tool will create ...


2

Make sure subtypes have not been defined for one of the fields in the feature class you are assigning a domain to. In the Feature Class Properties, choose "Subtypes". If a subtype field has been defined, click into each row in the table "Subtypes" and add the domain in the table "Default Values and Domains" below. A dropdown menu will appear only for the ...


2

It is likely because you are attempting to copy directly from a .MDB file. I have just noticed this issue copying sewer and manhole features within a .MDB to another shapefile. IT doesn't happen every time, but probably has something to do with linking of attribute fields. Fix: Export those layers (you are trying to copy from) to another shapefile saved ...


2

Try this if("laeskaerm"='1' OR "laeskaerm"='true','true','false') in 2.2 Case when "laeskaerm"='1' OR "laeskaerm"='true' then 'true' Else 'false' End


2

You could use the following expression to update your "laeskaerm" field: CASE WHEN "laeskaerm" = 1 THEN 'True' WHEN "laeskaerm" = 2 THEN 'False' ELSE "laeskaerm" END


2

Edited To clarify, do you have multiple fields that you are trying to delete OR multiple values concatenated together in one field that you are trying to split apart or extract a certain portion of. If it is the latter, my apologies, but if it is the former, then my answer still applies. I usually use the Delete Fields tool in the Data Management Tools > ...


2

It would be more convenient if you had a TripID field to identify the pairs. Right now, I assume they go after each other (first two rows for TripID = 1, next two rows for TripID = 2 and so forth). You could use Python if you are comfortable with scripting to select each point in the trip pair (start, end) and test whether both of them are within the ...


2

Assuming your source data is a FeatureClass/Table in a File GeoDatabase then the following query will select the rows you require: SUBSTRING(name FROM 1 FOR 7) = 'BENNETT' AND SUBSTRING(name FROM (CHAR_LENGTH(name) - 6) FOR 7) = 'BENNETT name is the field, I just happened to call it name. The first part is testing the left hand side the second part is ...


2

To add a column containing some attribute of a feature of another layer, with which there exists a topological relation: Define a function: layer properties -> attributes -> field calculator -> function editor Input code which does the work Eg is_contained_in() returns the value from column of feature from B which contains feature A from qgis.core ...


2

Field calculator expression based on this answer def cw(sentence): words = sentence.split() counts = {} nMax=0 for word in words: if word not in counts:counts[word] = 0 counts[word] += 1 nMax=max(nMax, counts[word]) return nMax '================================================== cw( !MUID!) It will return maximum count of same words in ...


2

As Stefan says, you have the wrong data, the basemap is just an image with no elevation data. A quick an easy way would be to download the 0m and 4000m Bathymetry data sets from Natural Earth, and clip the 0m shapefile with the 4000m shapefile (use Erase tool in ArcGIS or Difference in QGIS). Or if you need a more detailed raster data set I'd recommend ...


1

After adding the shapefile in QGIS,right click the layer and select properties, from there go to the Style tab and select Categorized This will allow you to change symbology based on a attribute, select the column you want to use (the attribute) and click classify this will add all the different attributes you can then style. Assign color to individual ...


1

To show that, it is just a rendering setting. Try the following: Right click on layer name in the Layers panel and select Properties Select the Style tab, Categorized drop down, and select the field that has the zones classes defined in the Column drop down Then click the Classify button and change the class symbol, size, and color as needed screen ...


1

If you join by id, as mentioned by @raphael, you could use the following expression in the Field Calculator which would replace values from the old column with those in the joined column. And if there's a NULL in the joined column, the old column will keep its original value: if( "JoinColumn" IS NULL, "Column", "JoinColumn" )


1

If you join the two layers by your unique ID, you will be left with one layer with 150 records and 2x the columns. In the attribute table just delete the extraneous columns and your old column. Then rename the new column to the old column name and save this layer over your old one and you should be golden.


1

You have the wrong data. The ESRI Ocean Basemap is designed as basemap. It's also cached, so you only have the image tiles available and therefore it cannot be used for analysis. You need to get a spatial dataset with x, y & z values in order to perform depth analysis.


1

First of all, I would suggest you to save your layer as a new layer once you have performed the simple join, in order to properly save the new attached columns in the layer attributes table. To achieve that: in the TOC, right-click on layer to save > Save As... and select Esri Shapefile for instance, which is the most currently used format (unless you need a ...


1

you need to create a new field in your attribute table and call it [Z] and make it float type, then do a field calculate on it making the new field [Z] = int([X]) once you have done this, you can run the stats on the new float field [Z] and it will work. you can never get stats on a field that is a string. you will always have to convert it to int or ...


1

I found a solution Instead of editing the fields myself I found a plugin that coould do the job (quickmultiattributeedit) Thank you for your help and time


1

the simplest way I would do it is to create a new column, lets call it ElevationINT, that is short-integer or long-integer (depending on which values you have in your initial data). I would then just do a simple Field Calculator on ElevationINT using the values from the Elevation column. All the integer values will be copied as is, however all the floating ...


1

A more robust soulution to mike's answer: long = toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '(-?\\d+\\.?\\d*) -?\\d+\\.?\\d*')) lat = toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '-?\\d+\\.?\\d* (-?\\d+\\.?\\d*)'))



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