|
POST
|
For your example field names D8739, D1983 field.name[1:4] is 873 and 198. You need to test field.name[0] == 'D' if field.name[0] == "D": gp.deletefield ("lyr", field.name)
... View more
07-28-2013
12:01 AM
|
0
|
0
|
1073
|
|
POST
|
import os
import shutil
import string
textfile = (r'C:\Offences\state_jul.txt',r'C:\Offences\state_jun.txt')
with open(r'C:\ArcReader_Servers.txt', 'r') as fp:
for filepath in fp.readlines():
filepath=filepath.strip() #Strip off the \r\n
print filepath
for filename in textfile:
print filename
shutil.copy2(filename,filepath)
... View more
07-27-2013
05:08 PM
|
0
|
0
|
1679
|
|
POST
|
spud007, Wayne is correct, have a read of the filename in the error message ( filename: 'C:\\\\Offences\\\\data\r\n'). Also, next time you post code, please use [noparse] [/noparse] tags, read this if you're not sure how. if this line textfile = (r'C:\Offences\state_jul.txt',r'C:\Offences\state_jun.txt') is supposed to be a list, then it must be enclosed in square brackets textfile = [r'C:\Offences\state_jul.txt',r'C:\Offences\state_jun.txt'] No, parentheses are fine. (r'C:\Offences\state_jul.txt',r'C:\Offences\state_jun.txt') is a tuple which is a sequence type similar to lists, but is immutable (can't be modified once created).
... View more
07-27-2013
12:44 PM
|
0
|
0
|
1679
|
|
POST
|
If the .sid rasters are Generation 4 you may need to upgrade to 10.1 or install the Lizardtech plugin.
... View more
06-25-2013
02:08 PM
|
0
|
0
|
875
|
|
POST
|
I had thought that the "MINOF" command was meant to set as the minimum of all inputs in a workspace, it's not very clear on the help. No MINOF tells ArcPy to set the output extent to the minimum extent of input datasets when running a geoprocessing operation, not all datasets in a workspace. If you wanted to run a raster calculation, setting arcpy.env.extent = "MINOF" would make arcpy perform the calculation only on the area where the extents of the input rasters overlap. If you printed arcpy.env.extent, you'd still get "MINOF", but if you described the output raster and printed its extent you'd see the actual minimum extent. If your question is answered, can you click the check mark to the right of the best answer.
... View more
06-24-2013
12:35 PM
|
0
|
0
|
1589
|
|
POST
|
Glad I could help. Can you click the green check mark next to the answer to indicate that it answered your question.
... View more
06-23-2013
09:25 PM
|
0
|
0
|
560
|
|
POST
|
See the arcpy ListRasters and Describe methods. Basically loop through the rasters in the workspace and describe them to get the extent and calculate the minimum. And here's an example: import arcpy # Set the current workspace arcpy.env.workspace = "c:/data/DEMS" # Get the list of rasters in the workspace rasters = arcpy.ListRasters() for raster in rasters: ext=arcpy.Describe(raster).extent try: xmin=max(xmin,ext.XMin) ymin=max(ymin,ext.XMax) xmax=min(xmax,ext.YMin) ymax=min(ymax,ext.YMax) except NameError: xmin,ymin,xmax,ymax=ext.XMin, ext.XMax, ext.YMin, ext.YMax minext=[xmin,ymin,xmax,ymax]
... View more
06-22-2013
05:47 PM
|
0
|
0
|
1589
|
|
POST
|
Sorry, I can't get it to fail. One suggestion is to open a new ArcMap window, add only the "Mosaic" raster to the TOC then run the raster calculator tool again (by entering all the parameters freshly not by rerunning results from previous sessions). For future reference, instead of screen grabs, you can copy the result messages as text by right clicking the "Message" entry in the result tree and selecting "Copy".
... View more
06-12-2013
06:12 PM
|
0
|
0
|
1518
|
|
POST
|
Your expression works fine for me in ArcGIS 10.1. What is the filepath of your output raster? I can replicate the "ERROR 000539: Error running expression: rcexec()" exception if I try to write out to a grid with non alphanumeric characters in the filepath. Can you post the full error message, i.e: ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 8, in rcexec
RuntimeError: ERROR 010240: Could not save raster dataset to C:\WorkSpace\test folder\test* with output format GRID.
... View more
06-11-2013
07:34 PM
|
0
|
0
|
1518
|
|
POST
|
I should add, all my testing is in the standalone IDE, not within the ArcMap python window. Which standalone IDE? Note that pythonwin uses the same python interpreter process for the IDE and for debugging. It's possible that any feature class locks created on the first run of a script will not get cleared (as the python process hasn't been restarted and the arcpy module is still in memory) causing subsequent runs of the script to fail. I moved from pythonwin to pyscripter a few years ago as it supports remote dubugging and the remote python interpreter is reinitialised before each run of the script.
... View more
06-11-2013
06:49 PM
|
0
|
0
|
1926
|
|
POST
|
It is reading the variable correctly (gridMin is equal to 0) but it seems like it doesnt know it is a number That's because it isn't a number. The getOutput method returns a unicode string, see the help for the result object. Cast your gridMax/Min variables to float before using them and the map algebra expression will work. >>> type(gridMax)
<type 'unicode'>
>>> gridMax = float(gridMaxResult.getOutput(0))
>>> gridMin = float(gridMinResult.getOutput(0))
... View more
06-11-2013
03:49 PM
|
0
|
0
|
1450
|
|
POST
|
Use 'Mosaic to New Raster'. Make sure Pixel Type is set to 32_BIT_FLOAT. If you get a 'dark piece of junk', don't worry, the data is correct, you just need to calculate statistics so ArcMap can stretch it for display.
... View more
05-27-2013
07:48 PM
|
5
|
4
|
11042
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM | |
| 5 | 04-22-2025 09:04 PM |