POST
|
I am writing a script tool that will take a list of rasters and stack them up so they align perfectly using resample and snap raster. I have the script written and the script tool assembled, but I keep getting this error: ERROR 000865: Input raster: D:\folder\file1;D:\folder\file2 does not exist. In my script tool, I have the parameters set so the input is a Raster Dataset and I have checked the multiple values box so I can input multiple rasters. I noticed that the raster is coming back as a semi-colon delimited string, so I tried both GetParamter() and GetParameterAsText(), but neither of them work: rasterList = arcpy . GetParameterAsText ( 1 ) . split ( ';' ) rasterList = arcpy . GetParameter ( 1 ) Based on some print statements it looks like the error is coming before it even gets into my script (none of the AddMessage statements return anything before the error is thrown), but I can add some of my code if that's helpful. I'll also add that if I only add one raster it works fine (well, it throws an error when it gets to a loop running through the list that it's supposed to be creating) but it doesn't give me an error about a file not existing. It looks like it's reading the semi-colon delimited string as one raster that does not exist?
... View more
10-07-2020
12:54 PM
|
0
|
0
|
70
|
POST
|
renaming datetime as dt when I imported it seems to have solved the issue. Thanks!
... View more
06-19-2020
07:52 AM
|
0
|
0
|
34
|
POST
|
I have a script tool that populates a "season" field based on the date of the point. For example, if the point is between Nov 1 and Feb 29, the "season" field is "Winter". It also looks to see if a particular individual is in a "nesting" or "brooding" list and, if so, that influences the season type. The tool works fine when I copy and paste the code in to the python window in ArcGIS Pro 2.4, but when run as a script tool, I get the following error: AttributeError: type object 'datetime.datetime' has no attribute 'datetime'. The error is thrown on line 11 below. Everything looks fine in the output and the print statements as I run it in the python window, as far as I can tell. It's probably something simple as this is the first time I've used the datetime module, but I'm confused why as a tool it won't recognize the datetime.datetime attribute import datetime full = "name of feature class" nesting = [ 'bird1' , 'bird2' , 'bird3' ] brooding = [ 'bird4' , 'bird5' , 'bird6' ] with arcpy . da . UpdateCursor ( full , [ 'Date' , 'Month' , 'Year' , 'Season' , 'SEX' , 'NAME' ] ) as cursor : for row in cursor : if row [ 3 ] == None : d = datetime . datetime ( int ( row [ 2 ] ) , int ( row [ 1 ] ) , int ( row [ 0 ] ) ) print ( d ) arcpy . AddMessage ( d ) if row [ 4 ] == 'MALE' : if d >= datetime . datetime ( int ( row [ 2 ] ) , 3 , 1 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 6 , 15 ) : row [ 3 ] = 'Breed' cursor . updateRow ( row ) elif d >= datetime . datetime ( int ( row [ 2 ] ) , 6 , 16 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 8 , 31 ) : row [ 3 ] = 'Summer' cursor . updateRow ( row ) elif d >= datetime . datetime ( int ( row [ 2 ] ) , 9 , 1 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 10 , 31 ) : row [ 3 ] = 'Fall' cursor . updateRow ( row ) elif d >= datetime . datetime ( int ( row [ 2 ] ) , 11 , 1 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 12 , 31 ) : row [ 3 ] = 'Winter' cursor . updateRow ( row ) elif d >= datetime . datetime ( int ( row [ 2 ] ) , 1 , 1 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 2 , 29 ) : row [ 3 ] = 'Winter' cursor . updateRow ( row ) elif row [ 4 ] == 'FEMALE' : #fall if d > datetime . datetime ( int ( row [ 2 ] ) , 8 , 31 ) and d < datetime . datetime ( int ( row [ 2 ] ) , 11 , 1 ) : row [ 3 ] = 'Fall' cursor . updateRow ( row ) #winter elif d > datetime . datetime ( int ( row [ 2 ] ) , 10 , 31 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 12 , 31 ) : row [ 3 ] = 'Winter' cursor . updateRow ( row ) elif d >= datetime . datetime ( int ( row [ 2 ] ) , 1 , 1 ) and d < datetime . datetime ( int ( row [ 2 ] ) , 3 , 1 ) : row [ 3 ] = 'Winter' cursor . updateRow ( row ) #Breed elif row [ 5 ] not in nesting and row [ 5 ] not in brooding and d >= datetime . datetime ( int ( row [ 2 ] ) , 3 , 1 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 6 , 15 ) : row [ 3 ] = 'Breed' cursor . updateRow ( row ) elif row [ 5 ] in nesting and d >= datetime . datetime ( int ( row [ 2 ] ) , 4 , 10 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 6 , 20 ) : row [ 3 ] = 'Nest' cursor . updateRow ( row ) elif row [ 5 ] in brooding and d >= datetime . datetime ( int ( row [ 2 ] ) , 5 , 5 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 9 , 1 ) : row [ 3 ] = 'Brood' cursor . updateRow ( row ) elif row [ 5 ] not in brooding and d >= datetime . datetime ( int ( row [ 2 ] ) , 6 , 16 ) and d <= datetime . datetime ( int ( row [ 2 ] ) , 8 , 31 ) : row [ 3 ] = 'Summer' cursor . updateRow ( row ) else : print ( 'assign point manually' ) else : print ( 'Type already calculated' ) cursor . updateRow ( row ) print ( 'done' ) arcpy . AddMessage ( "Complete" )
... View more
06-18-2020
10:20 AM
|
0
|
2
|
107
|
POST
|
Updates since yesterday: Bruce: I ran the tool you linked to and it finished running. I set it to comma delimited and it gave me a .tsv file which I'm having trouble opening, but based on the file size it looks like it's the same number of points I've been getting from the other methods I've tried. The points are just a feature class in a file GDB. I realized as well that I needed an XY field to reload the points back into ArcPro after the work in R Studio if I go the .csv route, so I ran the Add Geometry Attributes tool. It ran for 25 minutes and got to 40%, then completed and it only calculated the values for the 3 million rows. I then discovered I have access to a machine with 32GB of RAM (compared with the 16 on mine), so I went and ran the Add Geometry Attributes tool on that machine. It processed for about 20 minutes and finished, but now my feature class only has the 3 million points and visually only covers about a third of what it did before. So, it appears I somehow deleted the 6 million points that weren't being touched. Now to find my backup/rebuild my point file... I'm thinking I'm going to try to abandon this method and go to working with raster in R Studio (the point file was generated using raster to point) and see if that will solve my issues. But it appears that there might have been some sort of RAM issue?
... View more
05-06-2020
09:49 AM
|
0
|
1
|
117
|
POST
|
The tools execute fine, the results just don't have all of the rows. I also noticed that if I open the attribute table and scroll to the bottom it works for about 30 seconds and then ArcPro crashes (without loading the last rows of the table). Could it be a RAM issue or something? Not sure if insufficient RAM would influence the tool results if it doesn't give me an error though.
... View more
05-05-2020
01:47 PM
|
0
|
0
|
117
|
POST
|
I have a point feature class that has 9.2 million rows (according to the counter on the attribute table) and ~50 columns. I am trying to get it in to R to run some statistical analysis on it. I'm having issues exporting the whole table in a usable format (it is only exporting around 3 million rows). A few things I have tried: 1. ArcGIS Binding (it only brings in ~3 million rows to R). 2. Copy Rows tool with .csv extension (also only getting ~3 million rows) 3. Subset Features tool with the parameters set as 33.3%, thinking I could export it 3 times and then merge it in R (this only gives me 1.2 million rows, or 1/3 of what I'm getting with the other two methods) 4. A python script that selects 1 million rows and exports it as an excel table, then selects the next 1 million rows, etc. This runs until the 3rd iteration and then ends (because I've reached this strange ~3 million number) 5. Exporting from ArcMap as a table (same thing) I'm a little confused because the attribute table is definitely saying that I have 9 million rows, but nothing else I try seems to recognize that. I'm not aware with any sort of limit of features on any of these methods (for example, a .csv should be able to handle 9 million rows, as does R Studio). Is there a limit I'm not aware of, or some sort of known bug with the attribute table and there really is only 3 million rows in my feature class? What is the best way to get a table this size as .csv format?
... View more
05-05-2020
12:40 PM
|
0
|
8
|
498
|
POST
|
I have a list of wildlife points that I'm collecting using Survey123, which I then load directly into a web map on ArcGIS Online. I have ~15 individuals, and I would like to set it up to automatically filter all but the last point. I am seeing posts on updating the SQL query to show only the point collected in the last day; however, I need my filter to be a little bit more variable than that. For example, individual 1 might be located on Monday and Friday, individual 2 on Wednesday, etc., and on Saturday I only want to display the Friday point for individual 1 and the Wednesday point for individual 2, and so on for each individual. I can do this within a web map or web app setting, I just want to dynamically see where the individual was last seen. What is the best way to go about this?
... View more
04-22-2020
08:53 AM
|
0
|
1
|
63
|
POST
|
I have a feature class with just under 9.5 million rows that I want to load in R Studio. Here is my code: arc.check_product() point = arc.open(path = "...\\my.gdb\\my_feature_class") point.df = arc.select(point) However, it says it only loaded 3.6 million rows in my R Studio environment. I know that R Studio should be able to handle all of the rows because the following works fine: dat <- data.frame(X=rep(0, 92500000)) I do have ~75 columns, so is there some other memory limitation I don't know about? Why would it not load my whole dataset? I have done this with several smaller datasets (~20k rows) without any issue. Thanks in advance
... View more
03-23-2020
08:42 AM
|
0
|
0
|
88
|
POST
|
I have a point feature class that has a unique ID field and a julian date field. I also have a pile of rasters in a geodatabase that have daily values that I want to extract to the corresponding date in the point file. I have already written a script that goes through and renamed them so that the julian date is tagged on to the end of the name of the raster. To do this, I have the following code: input = point feature class #Iterate through to extract values to points based on date arcpy . env . workspace = #geodatabase with the rasters fl = arcpy . ListRasters ( ) dict = { } for feature in fl : j = feature [ - 5 : - 1 ] + feature [ - 1 ] #returns the julian date with arcpy . da . SearchCursor ( input , [ "julian" ] ) as cursor : for row in cursor : if row [ 0 ] == int ( j ) : temp = #temporary output string table = arcpy . sa . ExtractValuesToPoints ( input , r 'string for geodatabase' + feature , r "ouput geodatabase" + feature + "_testtable" ) with arcpy . da . SearchCursor ( table , [ 'ID' , 'RASTERVALU' ] ) as cursor2 : for row2 in cursor2 : ID = row2 [ 0 ] value = row2 [ 1 ] dict . update ( { ID : value } ) arcpy . Delete_management ( table ) else : print ( 'not equal' + str ( row [ 0 ] ) ) with arcpy . da . UpdateCursor ( input , [ 'ID' , "Value column" ] ) as cursor : for row in cursor : row [ 1 ] = dict [ row [ 0 ] ] cursor . updateRow ( row ) I think the problem is line 15; the input for the Extract Values to Points tool is being overwritten by the last raster that it iterates over. So, the values for November 6th are writing over all of the previous dates in the dictionary and subsequently the point feature class. How do I code this so that it only runs the Extract Values to Points tool on the selected row in the search cursor?
... View more
02-04-2020
09:34 AM
|
0
|
2
|
82
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|