Tag Info

Hot answers tagged

5

You could try something like this: for the scenario shown above, the script below import arcpy roads1 = #path to roads layer 1 roads2 = #path to roads layer 2 r1 = [row for row in arcpy.da.SearchCursor(roads1,["SHAPE@","NAME"])] #add field to hold required string arcpy.AddField_management(roads2,"COMMENTS","TEXT") with ...


4

Here is the code that should work for you: import arcpy mylist = ['A4126','A4190'] print str(tuple(mylist)) tempFeat_1 = r"C:\ArcGIS\Default.gdb\AR_postalcodes" tempFeat_2 = r"C:\ArcGIS\Default.gdb\AR_postalcodes_sel" qry = """POSTCODE IN {0}""".format(str(tuple(mylist))) arcpy.Select_analysis(tempFeat_1, tempFeat_2, qry) A couple of comments: ...


4

# I know I repeat myself. Any idea to avoid it ? Move secteur = row.secteur outside the if/else statements (before if nbrow > 0:). Move rows = arcpy.SearchCursor(pochoir) inside the for loop (after for fc in fcList:) I think that you aren't accessing the geometry properly. Reference Reading Geometries and Working with geometry in Python. # tells ...


2

So you want to convert all values to the same constant value and NoData should remain NoData. Instead of Reclassify, use the Con tool with your input raster as 'Input conditional raster', and the constant value as 'Input true raster or constant value'. E.g.: import arcpy cst = 5 # your constant value outCon = Con(r"C:\data\intput.tif", ...


2

Doesn't the third example script in the link you mentioned do exactly what you want in a single table? # Import system modules import arcpy # Set environment settings arcpy.env.workspace = r"C:/data/Habitat_Analysis.gdb" # Set local variables intable = "FIELD_NAME" outtable = "C:/output/output.gdb/TABLE_OUTPUT" # casefield = "Name" Not used stats = [] # ...


2

Take a look at this tool Feature Class To Feature Class (Conversion), the help section contains sample scripts if you want to go the arcpy path. Right clicking on the tool reveals a "batch" option, you can set the names how you want.


1

I would use a SearchCursor wrapped in a generator to get the summed fields. This is the full workflow: List all of the fields Create a function with a SearchCursor wrapped in a generator Loop through the fields Limit the fields to only those that are necessary with logic and implement the function import arcpy, os fc = ...


1

Have a look at the ListFields function. Note, you'll want to limit your results to numeric only fields, otherwise, you might get an error. So, you may want to use something like the following: int_fields = arcpy.ListFields("C:/data/Habitat_Analysis.gdb", , "Integer") to get a list of all integer fields. then small_int_fields = ...


1

I believe your code placement for the cursor and indentation is incorrect to get all of the lines you want. You should only need to create the insert cursor once before reading your dictionary. Also I do not see the da InsertCursor help recommend using the with syntax (although if you did use the with syntax do it with this layout and indent the entire ...


1

I do this by creating routes from the lines using the Create Route tool to get the lines with common ID attributes (like a river name) all combined together and oriented in a single direction. Then extract the FROM and TO end points of the original lines into separate point feature classes with the Feature Vertices to Points tool. I use the Locate Features ...


1

Without seeing the model or the exported Python script it is hard to say this definitively but ... If you have the line below in your Python script: arcpy.env.overwriteOutput = True then it should take care of ensuring that what you try to write can be written. Alternatively, you could use two lines like the following to ensure that the outputFC does ...


1

Try this: CadastreOut = "C:\\" arcpy.MakeFeatureLayer_management(Cadastre, "cadastre_lyr") arcpy.MakeFeatureLayer_management(Buffer_5km, "buflayer") field = "SiteName" cursor = arcpy.SearchCursor("buflayer") for row in cursor: geometry = row.getValue("Shape") out = str(row.getValue(field)) ...


1

The where clause is currently evaluating stepos literally as the value stepos, not the variable value 22. Move the stepos variable outside the where clause string, casting the numeric value to a string, like: arcpy.UpdateCursor(stefile, ' "POSITION" = ' + str(stepos))


1

Once you get the year you should be able to just assign it to parameters[0].value. Also there is an example that may be useful to you here. Look at the first example from the top of the page where it writes param1.value = 'sinuosity'.



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