POST
|
As an update (this is an old thread, but in case it's ever useful): Subsetting the process by breaking it up did seem to resolve the issue, so I am assuming at this point that the problem was in the architecture of the operating system (i.e. exceeding memory or the limits of a 64-bit system).
... View more
07-09-2021
01:30 PM
|
0
|
0
|
600
|
POST
|
Is there a simple way to expand the extent of an existing raster (using nodata values)? I have explored the following: Extending an existing raster extent. Increasing raster extent by filling extent with no data using ArcGIS Desktop without Spatial Analyst? - Geographic Infor… And I came across another posting (sorry, the link is not readily coming up) in which someone (Dan Patterson I think) recommended combining the starting (small) raster, and overlaying with another larger raster. Makes sense, and I have run the following: # Expand the size of the data raster, using a NoData raster of the correct extent.
emptyraster = Raster("examplerasterofdesiredsize") # Make a copy of a raster that is of the correct size
emptyraster = SetNull("examplerasterofdesiredsize","examplerasterofdesiredsize","VALUE = 0") # The raster being used is already populated with the value 0, this is converted to NoData
emptyraster.save("emptyraster") # save the no data raster
So far so good.
outputraster = Con("smallraster","smallraster","emptyraster") # Where there is a value for the small raster, use it, otherwise use the value from the larger raster
outputraster.save("outputraster") Unfortunatly, the outputraster retains the same extent as the small raster. There are ways to change this going through the GUI menus, but I would rather automate the process. Should the Con function work? Thanks.
... View more
04-30-2020
03:16 PM
|
0
|
1
|
1140
|
POST
|
Two more failed efforts. Using the Field Calculator GUI, the VB code: year = DatePart("yyyy",[fulldate]) seems to work. But, using the arcpy line arcpy.CalculateField_management(datatable,year,DatePart("yyyy",[fulldate]),"VB") generates the error arcpy.CalculateField_management(datatable,year,DatePart("yyyy",[fulldate]),"VB") NameError: name 'DatePart' is not defined It is not clear to my why the VB script is not working. But as an alternative, it seems that I could instead use arcpy.CalculateField_management(datatable,year,expression,"Python_9_3"), and use something like expression = !fulldate!.year since the field fulldate is already defined as a date field?
... View more
04-21-2020
02:59 PM
|
0
|
1
|
2011
|
POST
|
That makes sense (and I am happy for a solution, ugly, elegant, or just odd), however would this approach require me to loop through each feature/row in the table, updating the value? It seems odd that there is not simply a function to export a year from a date field as a "FLOAT", or other format. Is datetime.datetime.strftime(!fulldate!, "%-m/%-d/%Y") the right tree to be barking up to extract the year? I appreciate your time with this, I am learning how little I know about arcpy. Robert
... View more
04-21-2020
01:24 PM
|
0
|
3
|
2011
|
POST
|
This is a screen shot from running it. However, it occurs to me that this also may not work (even if it does populate the field), since it will attempt to extract characters 5 through 9, and since months and days can include 1 or 2 digits, the indices would shift.
... View more
04-21-2020
01:04 PM
|
0
|
5
|
2011
|
POST
|
Hi Jake, thanks for the suggestion, I gave it a try, but it generated the same issue the VB language generated. The process runs and closes successfully and does not generate any errors, but the field remains blank.
... View more
04-21-2020
12:34 PM
|
0
|
7
|
2011
|
POST
|
I recognize this is a question that has been asked before (I have included some links and strings below that are related), but I have not found a solution, and I am likely making a mistake that is now opaque to me, so I am hoping for assistance here. The solutions I have found seem to use Arcade, VB, and/or the GUI Field Calculator (the Field Calculator works, but I would like to automate the process in a script). What I I would like to do is create a new field "inspectionyear", and populate it with an integer for the year, extracted from another date field "inspection_date". Creating the new field is straight forward. # Import modules
import arcpy, datetime # Provides access to arcpy tools
from arcpy import time
from datetime import *
# Add a new field to contain the year integer
arcpy.env.workspace = "C/DataFiles/DataSource.dbf"
arcpy.DeleteField_management("DataSource.dbf","inspectionyear") # If a field with the name "yearvalue" already exists, delete it
arcpy.AddField_management("DataSource.dbf","yearfield","INTEGER") # Create the field that will hold the year integers. However, I have not successfully extracted the year values and added them to the new field. I have tried using the GUI Field Calculator as shown: The process runs and closes successfully, with no errors, however, the inspectionyear field remains populated with <NULL> I have also tried using the VB function in arcpy arcpy.CalculateField_management(inputtable,"inspectionyear",DatePart("yyyy",[fulldate]),"VB") which produces: NameError: name 'DatePart' is not defined and I have also tried: datevalues = datetime.datetime.strftime(!inspection_date!,"%-m/%-d/%Y")
To simply retrieve the year, but end up with a syntax error. Can someone recommend a way to retrieve the year value, or point me in the direction of a guide? I have already explored quite a few links, including but not limited to the following. Arcade approach Matching question posed by other user, but not answered Field Calculator GUI method that ran, but did not populate the field Info on generating datetime objects Thank you, Robert
... View more
04-21-2020
11:17 AM
|
0
|
10
|
2532
|
POST
|
Typically I have found the help topics very helpful (pardon the redundancy there). However they sometimes have limits, and I was searching for a good primer (book, course, etc) that goes through the basic background on syntax and data structures, as I've run into a wall with a very simple issue with dates and seem to be going in circles. When that happens I sometimes find it helpful to go back to some basics. Cheers
... View more
04-21-2020
09:09 AM
|
0
|
0
|
558
|
POST
|
Although I am familiar with Python, Arc, and arcpy, I am running into some fundamental issues with extracting values from a year field to populate a new field, rather than ask people to tutor me on the topic, an anyone recommend a primer or introduction for the topics? Searching through the questions asked produces some useful, but very specific information, I am searching for something more general that might provide useful generalized syntax. Thanks. Robert
... View more
04-20-2020
02:35 PM
|
0
|
2
|
601
|
POST
|
Hi Dan, this sounds like a great solution, I have been using both the "arcpy.GetParameter" and the "arcpyGetParametersAsText". The GetParameter function has been useful and simple to use, as long as there is a Data Type that fits the data set well. I will give this a try and let you know how it goes. Cheers, Robert
... View more
03-31-2020
02:09 PM
|
0
|
0
|
1226
|
POST
|
I running a script using the Toolbox in ArcMap, and the script requires inputs to run. Most of these inputs such as file names and folders are pretty straight forward. However, some of the parameters the script uses are simple floating numeric values. The list of parameter types includes "Any Value", and "Long", but these do not work. "Long" requires an integer, and "Any Value seems to behave as though it is looking for a data set. I can simply set the values in the script, but I want to be able to hand off this tool to folks who would use it in the Toolbox, rather than having to access the script directly. Thanks, and my apologies for what is likely a simple problem!
... View more
03-31-2020
01:42 PM
|
0
|
6
|
1281
|
POST
|
forgot to mention, I have not been successful in getting functions to run in arcpy (using the def approach). I get a syntax error using a simple "def functionname(var)" command, but that is probably a problem for another thread.
... View more
11-23-2018
09:52 AM
|
0
|
1
|
853
|
POST
|
I did indeed end up "floating" it as a workaround. By using it incrementally, do you man by imbedding it in a loop or a function? And you are right about it not being limited to an integer, I was thinking of the Reclass tool, which does seem to be limited. Thanks!
... View more
11-23-2018
09:50 AM
|
0
|
0
|
853
|
POST
|
I have also had the same issue. A Reclassify tool like the one available for rasters would be great (maybe re-using the RemapValue and RemapTable functionality?).
... View more
11-23-2018
09:03 AM
|
0
|
0
|
2666
|
Online Status |
Offline
|
Date Last Visited |
07-09-2021
03:08 PM
|