We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

10

It can be done with an expression. Bear in mind this only works if the original table is already ordered with N descending as feature IDs increase. Since the result field is empty, we need to get past NULL values ruining the calculation. We'll use a conditional statement to fill the first line with a different value than the rest, so subsequent calculations ...


9

Simply use Field Calculator and create new field with min(A,B,C) where A, B, C, are field names If you need to keep the field (min_ABC) updated, set the expression to default value of the field. It can be done in Attributes Form setting in Layer Properties. Scroll down in the right part of window fill the default value and check Apply default value on ...


5

As a workaround, you could write out the csv file yourself: import os, csv import arcpy def table_to_csv(table, csv_file, fields, where_clause=None): """ Example to export a table or feature class attribute table to CSV""" with open(csv_file, 'wb') as csv_file_obj, arcpy.da.SearchCursor(table, fields, where_clause=where_clause) as rows: ...


4

Use a formula to divide by 100.


4

Another variation, using list comprehension and da.SearchCursor: import arcpy shapefile = r'C:\folder\shapefile.shp' endx, endy = [i for i in arcpy.da.SearchCursor(shapefile,['LastX','LastY'])][-1] #-1 index for last record in list lastpoint = arcpy.Point(endx, endy) Im assuming LastX and LastY are fields. If you want the centroid's X and Y you can replace ...


4

You can use your field calculator for this. Add a new text field to your table that will be your key field. Right-click on its field name in the attribute table and choose Field Calculator... Use [ColA] & [ColB] & [ColC] for your field calculation.


3

I discovered I can use the edit session with Arcpy's Editor class. http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/editor.htm # Create an edit sessions edit = arcpy.da.Editor(arcpy.env.workspace) # start edit session # undo = enabled # multiuser = False to allow full control over a nonversioned / versioned dataset edit.startEditing(...


3

A variation on getting the last row could also be this approach, it gets a count on the row and then queries for that specifically: objRes = arcpy.GetCount_management("myLayer") n = int(objRes.getOutput(0)) sQuery = "OBJECTID >= " + str(n) with arcpy.da.SearchCursor("myLayer",["X","Y"],sQuery) as cursor: for row in cursor: x = row[0] ...


3

You can use python. Lookup table: Note that all intervals need to have a start and stop, with a '-' sign between them. So "53000-" need to be "53000-100000": import arcpy lookuptable = r"D:\lookuptable.csv" lookupview = 'lookupview' arcpy.MakeTableView_management(in_table=lookuptable, out_view=lookupview) columnlist = [f.name for f in arcpy.ListFields(...


3

select all your '0' rows -> Go to 'Select by expression' and select all rows where attribute = 0 Go to 'Field calculator' and check 'Update existing field', 'Only update selected features' and select your field = NULL


2

I just tried this in 10.6.1 running on Windows 10. I added a test field called "PASSING_400_MICROM" and set all values to be "YES". When I went to tun the Table to Table tool and set the output to be a CSV file it truncated the field name to 11 characters. I tried editing the field map and it set it back to 11 characters. My gut feeling is that this tool is ...


2

You can remove the geometries by setting them to "null", like this (https://code.earthengine.google.com/e8812348780874f1ac9d54a080fc4071): // Add reducer output to the Features in the collection. function protected_areas (image, select_country) {var pas = image.reduceRegions({ collection: select_country, reducer: ee.Reducer.frequencyHistogram(), scale:...


2

There is actually a very simple trick. Suppose you want to sort by field "A" first, and then by field "B" within "A". First left click on the header of the field "B" (click once for ascending sort, a second time for descending) in the attribute table. Then left click on the header of field "A" (once for ASC, 2nd time for DESC). This last action will have ...


2

cursor = arcpy.SearchCursor(shapefile, None, None, None, "FID A") row = None for row in cursor: pass #row is now set as the last value returned by the iterator row.getValue("the field you want the value of") arcpy.SearchCursor returns an iterator, and to get the last item you need to iterate through all the items and keep a reference to the last one. ...


2

If you want to add a new row and calculate as zero you should use the da.InsertCursor: InsertCursor establishes a write cursor on a feature class or table. InsertCursor can be used to add new rows. import arcpy table = r'C:\Users\a48384\Desktop\00_ArcGis\Daten\netzplan' fn_LEN_NS_FREI = "LEN_NS_FREI" fn_NS_VERKAB_GRAD = "NS_VERKAB_GRAD" fn_LEN_NS_KAB =...


2

Not that I know of. The only way I know of is to change the edit widget type from value map to the default widget for that data type, eg range for numerical fields. That's not a good solution because you'll lose your value map settings. You can save different widget types as separate layer styles, and switch between them, but that's a bit cumbersome. As a ...


2

You have an odd situation here. First you have to specify a list of the tables you want to exclude. Second, you have to specify the fields you want to exclude from each table. Having specified these two things, you can move forward and call arcpy.TableToGeodatabase_conversion() on all the tables but the ones you want to exclude. However, this tool does not ...


2

You can specify the GDB as your workspace and then use the arcpy.ListFeatureClasses() function to get all the names of the features in that GDB: import arcpy arcpy.env.worskapce = r'C:\path\to\my.gdb' for fc in arcpy.ListFeatureClasses(): arcpy.MakeFeatureLayer_management(fc, "lyr") arcpy.SelectLayerByAttribute_management("lyr", "NEW_SELECTION", '"...


2

You can do it but not with just one tool. You can create a model with the following process: Merge vector layers. Use the plugin: 'Dissolve with stats' and make sum. This will join all the value and, in this case, if you have a value of 2 means that the species is within both polygons. Notice that this 'Dissolve with stats' tool can't make sum with null ...


1

Tested on QGIS 2.18 and QGIS 3.4 In case if you do not want to modify your original data than I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume we have three features in "layer" with three values accordingly, see image below. With the following Query, it is possible to achieve the result SELECT ...


1

The two points are in 4326, so the where condition WHERE ST_Dwithin (a.geom,b.geom,500) is looking for points within 500 degrees of each others. You could also cast to geography here WHERE ST_Dwithin (a.geom::geography,b.geom::geography,500) Also you don't need the length + shortestline. Computing the distance directly will give the proper result SELECT ...


1

Via DB-manager: you can load the table into QGIS. Then connect to another database import the layer_styles-table Or you can create an empty table in the target_database: CREATE TABLE public.layer_styles ( id integer NOT NULL DEFAULT nextval('layer_styles_id_seq'::regclass), f_table_catalog character varying COLLATE pg_catalog."default", ...


1

As of today, working with SAGA through QGIS 2.18 Processing Toolbox would be safer than the latest QGIS 3 (I appreciate your [qgis-2] tag for that reason). You can use any text format to create the Pairwise Comparisons Table, as far as it can be read by QGIS. I would suggest csv format, as I can just drag and drop it onto QGIS window. (1) Create csv file; ...


1

Those fields are most likely blank because whoever created the features didn't fill in the optional fields. That's pretty common with OSM data. You can read more about how Open Street Map works here. If you have local knowledge about data that's missing from OSM, consider becoming an OSM contributor. The other possibility is that the QuickOSM plugin is ...


1

An ArcGIS solution here. The Point Distance Tool will calculate distances from each input point to all points in the other layer. You can delete the records greater than your tolerance. Finally, run Summary Statistics to find the minimum distance for each input Objectid/FID.


1

Dan has a good answer already posted but just to clarify why your code is failing: length is related to the number of rows, while row[length-1] is a specific column index (which probably doesn't exist since there's often more rows than columns. e.g. length = 53 (number of rows) would cause an error in general if there aren't 53 columns. An in-place fix ...


1

Problem with my code was that I was using the 'CopyFeatures_management' function, which seems to expect a 'Feature Class' but I was trying to copy a static table. The code below copies static tables and is working for me. gp.CopyRows_management(r"C:\path\Irfan_Simple_Input_TBL.gdb\IrfanTable1", r"C:\path\OUTPUT\db_output.gdb\IrfanTable1")


1

Yes, there is a service to do that. It is called reverse geocoding and there are a few providers out there who can do that for you. The ones that are completely free will have some location offset from the actual target that can be from 50 miles to 1000 feet. An example of such a service is OpenStreetMap. If you follow the OSM link for an address 99 Monroe ...


1

As suggested by Paul, use arcpy.ListFields() to get a list of columns names from variable table and loop through it: import os import arcpy from arcpy import env table = "table1" fields = [f.name for f in arcpy.ListFields(table)] arcpy.DeleteIdentical_management(table, fields)


1

Fast and Best way to reclassification Raster in Qgis 3.2, 3.4, 3.6 version: From 'Processing toolbox', on "Raster terrain analysis"; open "Slope" and then fill up the required parameter (just provide your raster as 'Elevation layer' as input, 'Z factor' Default: 1, after that, you will get slope raster. On "Raster analysis"; open "Reclassify by table" ...


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