New answers tagged

0

You could easily achieve this with modelbuilder: use a featureclass iterator to iterate over your shapefiles, this feeds into an add field, then calculate tool using inline substitution from a parse path tool to store the file name. Once you have run that you can run a merge tool bring them altogether into a single dataset. Basically read the help file and ...


2

Depending on what attributes you have in your states you can join them based on location using QGIS. The tool can be found at "Vector"-"Data Management"-"Join attributes based on location". Your target will be your shp1. It then should bring you all attributes from your states.


0

In this case, anyway, I decided that I need to calculate all fields for each of the two feature classes individually, before they are merged. Then, when merging the two, I will use field mapping if necessary (although, if the fields have the same name, they will be merged into one field even without field mapping, as I've discovered).


1

To continue with your code sample: import arcpy mxd = arcpy.mapping.MapDocument("Current") fc = r"W:\\GIS_Projects\\Impervious_Surfaces_Tables\\TOTAL" field1 = "SURFACE_TYPE" field2 = "SUM_SQ_FT" value = "" with arcpy.da.SearchCursor(fc, [field1, field2]) as cursor: for row in cursor: if row[0] == "BUILDING": value = str(row[1])...


1

If you use a spatial join you can append the attributes of one dataset to the other. If you are trying to fill a particular field you can then just copy it across using the field calulator


1

You can select-scroll (scroll-select?) through records of an attribute table with Ctrl + Enter, which will also highlight the feature on the map. If you only want to scroll through a selection of features, you can create a layer from your selection first, and then scroll through that attribute table. I was looking for this today, so I found your question ...


3

You could create a Custom function in the Function Editor to use the python ORD() function to get the ASCII value of a character (A being 65): http://www.qgistutorials.com/en/docs/custom_python_functions.html The function might look like this: from qgis.core import * from qgis.gui import * @qgsfunction(args=0, group='Custom') def ord_place(value1, ...


1

In your Field Calculator interface, go to the Function Editor tab, create a new file and input the following code: from qgis.utils import qgsfunction from qgis.core import QgsExpression, QgsMapLayerRegistry @qgsfunction(args="auto", group='Custom') def stringtoNum(field, feature, parent): val = dict(zip(string.letters,[ord(c)%32 for c in string.letters]...


3

Right-click on your layer in the Layers Panel and then click on Open the Attribute table. Click on Open field calculator (CTRL+I). There, create a new (virtual) field with the following expression: CASE WHEN col1 = 'A' THEN 1 WHEN col1 = 'B' THEN 2 WHEN col1 = 'C' THEN 3 ELSE 0 END Edit: you can also use strpos to return the position of ...


0

you are right that you can use the field calculator, but you could also do this with a cursor. With the field calculator, you can define a function that take all your fields as input and gives the position of the field as an output. argmax(!field1!,!field2!,!field3!,...,!field15!) def argmax(a,b,c,...o): mylist = [a,b,c,...o] return mylist.index(...


3

To elaborate on FelixIP comment, the ordering of your fields in the attribute table is determined by the order set out in the pop up configuration.


0

Assuming you are using QGIS because you mention "attribute table", as Pierre states , you can add a new field and populate it with the year. Another function that is available is YEAR(date): From the expression dialog: function year Extract the year part from a date, or the number of years from an interval. Date variant Extract the ...


1

One way is to create a new field containing your year, so you can count on it, and keep the full date for a later use. Use the function 'right' to fill your new field with the last four characters of your date field (only the year) : right( "dateField" , 4 ) This works with QGIS, but equivalent functions exists in other softwares.


6

This will need you to modify values based on your GRIDCODE as I can only see 4 and 16 in your table, but to do this in the Field Calculator is fairly straightforward. In the Field Calculator window, select Python parser, and select Show Codeblock. Enter the following into the Pre-Logic Script Code textbox: def updateName(gCode): if gCode == 4: ...


0

I would do a dissolve on the shape file so that the shape file only contains a single entry based on country you can them label as required


4

If you already have the Name field, as your images shows, then right-click on the field header and select "Field Calculator...". In the field calculator window, enter an expression in either VB Script or Python which checks the value of GRIDCODE and returns the appropriate name for each of the four possible values. To calculate the total area for each ...


-2

Zonal stats worked perfectly thanks!! This is the video I found that explains how to use zonal stats: https://www.youtube.com/watch?v=HO1jNZitQBI


1

Try Zonal Statistics or Zonal Statistics as Table Tool. The first I mentioned works with input raster dataset that you want to calculate statistics from and raster dataset or feature class that defines the zones. Only one statistics a ta time is supported here and you can select it from the drop-down menu. Result is raster dataset I think with the ...


2

It would be helpful if you posted your code. There is now a special merge function that is called for sp class objects that addresses the sorting issues with base merge breaking the slot relationships. You can bring up help for the sp version of merge using ?sp::merge. The slot id should be the same as the rownames in the @data slot. As such, you can use ...


4

You need to connect the parts with AND or OR. ( "highway" ILIKE '%primary%' OR "highway" ILIKE '%secondary%' OR "highway" ILIKE '%tertiary%' OR "highway" ILIKE '%trunk%' ) AND "highway" NOT ILIKE '%trunk_link%'


1

In the bottom right-hand corner of the 'select by expression' window, there is the 'select' button: pull the drop-down to reveal the 'remove from selection', 'add to selection', etc. That should do it.


0

Actually I did find a round-about way to edit related tables on ArcGIS online. You can create a filter for the feature or features you wish to edit then run a field calculate on that particular feature. I used the OBJECTID field to select a particular feature and calculate values. I am sure with some smart programming in the JavaScript API this could be ...


0

Take a look at this page, I think the code provided in that page is similar to what you are trying to achieve. Once you are done with creating csv files or text files, you can merge them easily into one single file in python. From my personal experince, I would suggest you to stay away from excel as your columns can get truncated depending on whether you use ...


0

Because that is the classical layout of the Shapefile, or geodata in general. The coordinates are not shown here since it would be not a good idea when you have for example a polygon with hundreds of points. Thats why the underlying geometry is stored differently. For the shapefile it is stored in the .shp file. Think of it as a small database with ...


2

If you want to delete all brackets in the column you go for: replace("your_column",'[','') It searches for all the brackets and replaces them by nothing. If it needs to be a special position where the brackets are you need to find them: For example by position with left, right or substr functions when the position is always the same in each line. If ...


0

Use the field calculator and insert an "if" statement or a "case" statement to populate the values in your "elevation" field. CASE WHEN "FID" = 0 THEN 1700 WHEN "FID" = 1 THEN 1740 END CASE WHEN "FID" > 1 THEN "CNG_(Meters)" END


10

Agree with @JochenSchwarze that it makes sense to have it (and thanks for making it a feature request). Saying that, it is possible to do it with a bit of Python. Make sure the Open attribute table in a dock window setting is enabled from the menubar: Settings > Options > Data Sources > Feature attributes and table > Open attribute... ...


5

Seems impossible at the moment. But I strongly agree that it makes sense. I have just started a feature request in the QGIS issue tracker https://hub.qgis.org/issues/14941


6

You can also use coalesce to replace NULL values from column_1 by column_5. coalesce("column_1", "column_5")



Top 50 recent answers are included