Hot answers tagged

4

Here's the documentation for the Describe Raster Dataset. There is no pixelType property there. However, as you can see at the top of the documentation, it can also include the properties for Raster Band ONLY IF the raster is a single-band raster. Here's the documentation for the Describe Raster Band. As you can see, a Raster Band, and hence a single-...


3

Assuming that you are simply asking how to get a string (text) representation of your spatial_ref spatial reference object that you can append to your report... Here is the documentation for the spatial reference class. If you examine the Properties section, you will find various properties that return a string (text). Eg, "name". You can use one of ...


2

One option would be to add the default value Incomplete to the STATUS field of the feature class after you truncate it. With arcpy you can do it like this, arcpy.AssignDefaultToField_management( outFeatureClass, 'STATUS', 'Incomplete' ) AcrGIS Docs - Assign default to field


2

In this case I've found it simpler and safer to use the children property of the describe object: if element_type == "RasterDataset": InRas = arcpy.Raster(element_description['catalogPath']) # make a raster object Desc = arcpy.Describe(InRas) PxType= Desc.children[0].pixelType InRas=arcpy.Raster(r'C:\PATH\TO\RASTER\Raster3band.png') Desc = ...


2

Create a layer object from your file path. You can update and save the layer file using layer object properties and methods. >>> lyrFl = r"C:\test.lyr" >>> arcpy.Describe (lyrFl).nameString #check name with describe u'mains' >>> lyr = arcpy.mapping.Layer (lyrFl) #create layer object >>> lyr.name u'mains' >>> lyr....


1

You can use an Update Cursor to populate a field based on values in another field. The following example has two fields general_plan, which has classified zoning data (e.g. "Residential") and coded which is an empty string field. You can use if/elif/else statements to add an integer classification code. For example import arcpy fc = r'C:\path\to\your\...


1

I think this example code I made for you might help you. Expression: harvesine(!user_id!, !lat!, !lon!) Code Block: dic = {} def harvesine(user_id, lat2, lon2): global dic if user_id not in dic: # first data dic[user_id] = [lat2, lon2] return 0 # calculate distance lat1 = dic[user_id].lat lon1 = dic[user_id]....


1

I am not completely sure that I understand your goal, but it I do so this example should work. I think you are "over" iterating, plus you are opening the file in each iteration and over writing the file. Check my proposition it may guide you, if it does not solve your problem let me know. import os import arcpy import traceback checkProjections = r"C:\...


1

Something funky has happened to your newline characters (ie, \n). The \ has been escaped with another \, so instead of a newline, you're getting \\n. Replace every instance of \\n with a \n newline (ie, delete one of the \ from each. It is using the newline character escape sequence \n rather than actual newlines, because it is a separate 'script-within-a-...


1

Try something like: import arcpy fc = 'points1' fields = ['Field1','Field2','Field3','Result'] with arcpy.da.UpdateCursor(fc,fields) as cursor: for row in cursor: row[-1] = max(row[:-1]) cursor.updateRow(row) You might need to change max(row[:-1]). For example if you can have None values in some field, it will fail. Then try max([v for ...


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