POST
|
I am making a script tool that will result in a point feature class, and I would like to update the symbology on that feature class in the current map so that the results are displayed the same for each user. I have a field with unique text values that I want to use for the symbology, and I'm trying to find a way to say "Value A is size 10 red point", "Value B is size 12 blue point", etc., without using a reference layer. Because this tool will be shared, it strikes me as cumbersome to have an additional layer that I have to share with the tool to get the same symbology. I've been digging around forums, etc. online for a while and can't find a solution in which the symbology is coded within the script tool. Any basic ideas for workflow or places I can go for answers is greatly appreciated! I am using ArcGIS Pro.
... View more
09-25-2019
12:52 PM
|
0
|
1
|
1059
|
POST
|
Thanks for your input. Making a new feature layer as my input as you described solved my problem.
... View more
09-17-2019
09:14 AM
|
0
|
0
|
4895
|
POST
|
I am trying to iterate through a field (integer values 1, 2, 3), select by each unique attribute, and run a tool on that selection of points. My list is: NearValues = [1, 2, 3] And my for loop is the following (again, I want to select all of the points with a value of 1, run the median center tool on all of those points, then select all of the 2's, etc): for value in NearValues:
query = "['nearstr']="+str(value)
arcpy.SelectLayerByAttribute_management(points, "NEW_SELECTION", query)
arcpy.MedianCenter_stats(points, "mediancenter_test" + str(value)) It's giving me an Invalid expression error, so I'm not sure if it's a minor syntax thing or if there's something wrong with my methodology. Here is the complete error if it's helpful: Traceback (most recent call last):
File "<string>", line 3, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 7605, in SelectLayerByAttribute
raise e
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 7602, in SelectLayerByAttribute
retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000358: Invalid expression
Failed to execute (SelectLayerByAttribute).
... View more
09-16-2019
01:50 PM
|
0
|
2
|
5370
|
POST
|
I have a big project that involves parsing many PDF's for locations and just got a LocateXT license to try using the Extract Locations from Document tool. So far, I've had mixed results. I've run the tool on 6 different PDF's; 2 of them work perfectly, 2 of them give me a bunch of garbage depending on the configuration of the tool but don't pull out the coordinates, and 2 of them won't give me anything no matter what I try. The successful ones were in DMS and DD, the unsuccessful ones were a mix as follows: Successful: 118°45'15.435"W, 42°33'14.25"N 40.174996° N, 111.072179° W Unsuccessful (116°W, 43°N) (lat 40°23'N, long 120°34'W). located at 49'41'N and 74"35'W (latitude 48°19'35"N, longitude 85°21'01"W) I've run all of them through with varying combinations of what types of coordinates to parse for, but as I copied and pasted the coordinates into this I noticed a lot of the symbols got messed up (° changed to 0, etc) so that might be part of my problem. However converting it to Word and txt files didn't solve the issue. My big question is has anyone had experience with this tool and has had success working through issues like I am having? Are there any resources you found helpful other than the tool documentation (https://pro.arcgis.com/en/pro-app/tool-reference/conversion/extract-locations-from-document.htm)? Any recommendations on how to make this more streamlined for processing many documents would be appreciated.
... View more
08-06-2019
09:53 AM
|
0
|
3
|
1906
|
POST
|
I am adding points to my point feature class within a file geodatabase, and then overwriting that on to the existing file on ArcGIS Online. After I do that, it looks like the online map and web app lose the connection with the layer and I have to re-add it. It's very possible I'm missing something obvious though
... View more
07-15-2019
12:39 PM
|
0
|
0
|
560
|
POST
|
I have a point feature class that I update about once a week using ArcPro, then I use "Overwrite Web Layer" to publish it to ArcGIS Online. It is in a fancy story map and this process has been smooth and has worked great until a couple of months ago. Now, I use "Overwrite Web Layer" to push it to the web, but when I load my online map it says that the layer cannot be added to the map (the layer that used to exist, but was replaced by the updated version moments before). I have to re-add it to the map and re-do all of my functions within the story map, etc to get it where it was before. It isn't that time consuming, but it's starting to be a real hassle. I'm not sure why it suddenly stopped working. I've made sure the names are the same, and I'm not really sure what else to look at. Is there something else I'm missing, or some other way I can improve my workflow so I don't have to manually correct my story map every time I update the layer?
... View more
07-15-2019
12:02 PM
|
0
|
3
|
626
|
POST
|
The points are locations from wildlife GPS collars, but I will look into the possibility of dissolving some of the buffers and consolidating areas a bit. Thanks for all your input
... View more
05-31-2019
09:34 AM
|
0
|
0
|
2088
|
POST
|
Here is an image of the ~400 that aren't processing (and then zoomed in so you can see some of the spacing) The raster cell size is about 0.6 meters. I took the selected points above (the ones that didn't process) and exported them as a separate file for good measure. I will also mention that in my code above, I get a key error, I assume because the zonal stats doesn't run so it doesn't return a value in the dictionary. Rerunning the code on the subset of the data works on the first ~200 points, and then throws a key error again. In the image below, the yellow circle in the last point that processed correctly, and the blue circle is the first one that didn't. I repeated this process another time after this (subsetting the data into a separate file and rerunning the code) and it again gave me a key error about halfway into the dataset. The last point that worked and the first one that didn't are similar to the pattern you see above. I'm down to my last 100 or so points so I could just repeat the process until it gets all of the points done and then combine everything into the original point file, but I will need to repeat this process with several other datasets so it's not the most practical solution.
... View more
05-31-2019
09:13 AM
|
0
|
2
|
2088
|
POST
|
Thanks Dan. However, when I compare results on a polygon without an overlap, the results are still inconsistent. Would the results from Zonal Statistics still be compromised by overlapping polygons even for the points that do not have overlapping polygons? Would the iterated results using As Table be more reliable? Also, another point I forgot to mention, Zonal Stats as Table is only running on about 900 out of the 1300 points. I've even tried subsetting my processing (i.e selecting the points that didn't process and running it again, skipping the point it failed on, etc.) and I couldn't get it to process the last few hundred points. I couldn't find any obvious reason in the data why that would fail. Any ideas on what I can check there?
... View more
05-30-2019
11:26 AM
|
0
|
4
|
2088
|
POST
|
I have a collection of about 1300 points and for each point I want to get the average of a raster layer within a 50 m buffer. I have overlapping polygons. I've been scouring the forums for days now and I still haven't been able to come up with a solution that works. Here's an idea of what my data looks like My current workflow is to to run Zonal Statistics as Table, digest it into a dictionary, and then use that to populate a field in my buffer layer. The following is my code (modified from something I found on a forum): out = output workspace
features = arcpy.Buffer_analysis(pointfc, out + '\\name', '50 Meters')
zone_field = "OBJECTID"
input_raster = raster file
field_name = "Average"
field_type = "DOUBLE"
stat = "MEAN"
import arcpy
from arcpy.sa import *
# Add zone field to features
arcpy.AddField_management(features, field_name, field_type)
# Clear path for temporary table
if arcpy.Exists("zonal_table"):
try:
arcpy.Delete_management("zonal_table")
except:
arcpy.AddError("Unable to clear temp table")
sys.exit(-1)
# Zonal statistics
print("Performing zonal statistics: " + field_name)
zonal_table = ZonalStatisticsAsTable(features,zone_field, input_raster, out + "\\zonal_table", "DATA", stat)
# Digest statistics from zonal_table
print("Digesting " + stat + " from zonal table")
stat_dict = {}
with arcpy.da.SearchCursor(zonal_table,[zone_field,stat]) as cursor:
for row in cursor:
stat_dict[row[0]] = row[1]
print("dictionary done")
# update new field in feature class
print("updating field")
arcpy.AddMessage("Calculating " + field_name)
with arcpy.da.UpdateCursor(features, [zone_field, field_name]) as cursor2:
for row2 in cursor2:
row2[1] = stat_dict[row2[0]]
cursor2.updateRow(row2) The process works; however, my results are mostly different than what I get from running Zonal Statistics and comparing the point to the underlying raster. All of my data is in the same projected coordinate system. I've seen that there are issues with the way the snap rasters are implemented and have tried converting my buffer to raster (outside of the code on a small subset to test) without any better results. I also saw that the underlying bug was resolved in 10.5, but I still have differing results between Zonal Statistics and Zonal Statistics as Table in both 10.6 and ArcPro 2.3. Is the issue with the Zonal Statistics or the Zonal Statistics as Table tool? Or is there another hole in my workflow somewhere I'm not considering? I'm about out of stuff to check, so any ideas are greatly appreciated.
... View more
05-30-2019
10:50 AM
|
0
|
7
|
2716
|
POST
|
The semicolon delimited string returned the following error: arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Rasters: Dataset blue does not exist or is not supported Failed to execute (CompositeBands). However, creating a list and using that in my input ended up working. arcpy.AddMessage("Running Composite Bands...")
list = [bluex, greenx, redx, nirx, rededgex]
arcpy.CompositeBands_management(list, outWorkspace + "\\" + outName) Thanks once again for your help Dan.
... View more
04-26-2019
11:46 AM
|
0
|
1
|
1217
|
POST
|
Here's the exact error line 46 arcpy.CompositeBands_management(bluex;greenx;redex;nirx;rededgex, outWorkspace + outName) ^ SyntaxError: invalid syntax Failed to execute (REtest).
... View more
04-26-2019
10:34 AM
|
0
|
0
|
1217
|
POST
|
I have a small image dataset collected by a UAV multispectral camera and I'm trying to make a script tool that merges 4 tiffs into one, for each band (4 blues into one blue, 4 greens into one green, etc) and then use the Composite Bands tool. It runs fine in the Python window (ArcGIS Pro 2.2) but the tool gives me an invalid syntax error and I'm not really sure what the error is. Here's my script: outWorkspace = arcpy.GetParameterAsText(0)
cell = arcpy.GetParameterAsText(1)
blue = arcpy.GetParameterAsText(2)
green = arcpy.GetParameterAsText(3)
red = arcpy.GetParameterAsText(4)
nir = arcpy.GetParameterAsText(5)
rededge = arcpy.GetParameterAsText(6)
outName = arcpy.GetParameterAsText(7)
###create empty raster datasets
arcpy.AddMessage("making raster datasets")
blue_T = arcpy.CreateRasterDataset_management(outWorkspace, "blue.tif", cell, '32_BIT_FLOAT', "", 1, "", "", "", "", "")
green_T = arcpy.CreateRasterDataset_management(outWorkspace, "green.tif", cell, '32_BIT_FLOAT', "", 1, "", "", "", "", "")
red_T = arcpy.CreateRasterDataset_management(outWorkspace, "red.tif", cell, '32_BIT_FLOAT', "", 1, "", "", "", "", "")
nir_T = arcpy.CreateRasterDataset_management(outWorkspace, "nir.tif", cell, '32_BIT_FLOAT', "", 1, "", "", "", "", "")
rededge_T = arcpy.CreateRasterDataset_management(outWorkspace, "rededge.tif", cell, '32_BIT_FLOAT', "", 1, "", "", "", "", "")
#####################################################################################
#Merge layers####################################################################
###combine blue layers#####################################################
arcpy.AddMessage("Merging blue...")
bluex = arcpy.Mosaic_management(blue, blue_T)
#################################################################################
#Combine green layers#############################################################
arcpy.AddMessage("Merging green...")
greenx = arcpy.Mosaic_management(green, green_T)
#Combine red layers#############################################################
arcpy.AddMessage("Merging red...")
redx = arcpy.Mosaic_management(red, red_T)
#Combine red layers#############################################################
arcpy.AddMessage("Merging NIR...")
nirx = arcpy.Mosaic_management(nir, nir_T)
#Combine red layers#############################################################
arcpy.AddMessage("Merging red edge...")
rededgex = arcpy.Mosaic_management(rededge, rededge_T)
##############################################################################
#composite bands
arcpy.AddMessage("Running Composite Bands...")
arcpy.CompositeBands_management(bluex;greenx;redex;nirx;rededgex, outWorkspace + outName) Everything through line 36 works perfectly, so I have 5 complete tiffs, one for each band. The error is coming in line 40. When I run it in the python window with the actual files and file paths (bypassing the variables) it works. So I assume it's an easy fix and I'm doing something wrong with concatenating my strings or something along those lines.
... View more
04-26-2019
10:32 AM
|
0
|
4
|
1338
|
POST
|
I am trying to calculate a "day of the year" field in a feature class using ArcPy. ###create day update cursor
cursorD = arcpy.da.UpdateCursor(featureclass,["month", "day", "dayoftheyear"])
print("day cursor set")
###loop and assign day of the year
for updateRowD in cursorD:
if 'month' == 1:
print("Jan")
"dayoftheyear" = [day]
cursorD.updateRow(updateRowD)
print("Jan completed")
elif 'month' == 2:
print("Feb")
"dayoftheyear" = [day] + 31
cursorD.updateRow(updateRowD)
print("Feb completed")
elif 'month' == 3:
print("Mar")
"dayoftheyear" = [day] + 59
cursorD.updateRow(updateRowD)
print("Mar completed") and continues throughout the rest of the year (April through December). I'm getting syntax errors on the lines where I actually calculate the day number (lines 9, 14, 19, etc). I just can't figure out the syntax to get it to read the value of a field (day), perform basic arithmetic on it, and assign it to another field (dayoftheyear). I've used lots of combinations of [day], "day", !day!, etc and haven't been able to find my answer in any documentation. Thanks in advance for your time and suggestions.
... View more
03-28-2019
08:08 AM
|
0
|
3
|
792
|
POST
|
Thanks for your input Dan. I've made those changes (and fixed a couple of other typos from switching around names I found) and now have the following. It runs without an error but doesn't update the table (the ID field is populated but the name is not). for row in cursor:
if row[0] in assignName:
row[1] = assignName(row[0])
cursor.updateRow(row) I'm beginning to think I don't understand either dictionaries or update cursors as well as I thought I did.
... View more
03-07-2019
01:21 PM
|
1
|
4
|
2574
|
Title | Kudos | Posted |
---|---|---|
1 | 11-26-2019 08:43 AM | |
1 | 02-21-2019 01:52 PM | |
1 | 03-07-2019 01:21 PM | |
1 | 01-24-2020 11:36 AM |
Online Status |
Offline
|
Date Last Visited |
01-27-2021
02:11 PM
|