|
POST
|
I don't have ArcGIS 10.3. Can you confirm that 10.3 still install numpy 1.7x? Don't try and install numpy 1.9 if so, you can break arcpy stuff, use the numpy 1.7 specific version of the gdal bindings I referred to. pip install -i https://pypi.anaconda.org/luke/channel/np17/simple gdal
... View more
01-23-2016
12:38 AM
|
0
|
1
|
7067
|
|
POST
|
Dan, Gohlke's stuff that I've tried works fine with ArcGIS installed python 2.7. There are a few gotchas though, mainly to do with C extension version compatibility. The version I repackaged is built against numpy 1.9 so should work with ArcGIS 10.3 For numpy 1.7 (i.e an ArcGIS 10.1 or 10.2 python installation) pip install -i https://pypi.anaconda.org/luke/channel/np17/simple gdal
... View more
01-05-2016
02:24 PM
|
1
|
3
|
7067
|
|
POST
|
For a repackaged version of Cristoph Gohlke's Unofficial GDAL Python bindings built against numpy 1.9 with the ECW and MrSID plugins included you can try: pip install --user -i https://pypi.anaconda.org/luke/channel/np19/simple gdal
... View more
01-05-2016
01:47 PM
|
0
|
5
|
7067
|
|
POST
|
I thought there was a way to do this easily with parameterDependencies, but can't get that to work. But below is another way: class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
in_feature = arcpy.Parameter(
displayName = "Feature with States",
name = "in_feature",
datatype = "Feature Layer",
parameterType = "Required",
direction = "Input")
stateField = arcpy.Parameter(
displayName = "Field with State Names",
name = "stateField",
datatype = "Field",
parameterType = "Required",
direction = "Input")
stateField.parameterDependencies = [in_feature.name]
stateName = arcpy.Parameter(
displayName = "Select one State",
name = "stateName",
datatype = "GPString",
parameterType = "Required",
direction = "Input")
stateName.filter.type = "ValueList"
stateName.filter.list = []
return [in_feature, stateField, stateName]
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if parameters[1].value:
with arcpy.da.SearchCursor(parameters[0].valueAsText, parameters[1].valueAsText) as rows:
parameters[2].filter.list = sorted(list(set([row[0] for row in rows])))
else:
parameters[2].filter.list = []
return
... View more
01-03-2016
09:24 PM
|
3
|
3
|
7973
|
|
POST
|
...as long as I can utilize the final product/composite file in Raster Calculator. I think you will find that no matter what you do you will not be able to analyse the final raster in the ArcGIS Raster Calculator. A global 30m dataset is just too big to analyse on a desktop PC. The Australian Geoscience Data Cube (time series Landsat over Australia) is analysed on the Raijin supercomputer and it is stored as 1x1 degree tiles not as individual continental scale rasters. Perhaps you could provide some more information about what you want to achieve?
... View more
12-16-2015
02:30 PM
|
1
|
1
|
3440
|
|
POST
|
The help (ArcGIS Help (10.2, 10.2.1, and 10.2.2) ) states the 1st parameter "in_probability_raster" should be a Raster Layer or a Mosaic Layer, not a Raster Dataset. When you add the Raster Dataset to the TOC, you create a Raster Layer which works in the tool. Try creating a Raster Layer with the Make Raster Layer (Data Management) tool and pass that as the "in_probability_raster" parameter.
... View more
12-15-2015
07:53 PM
|
1
|
1
|
2610
|
|
POST
|
ArcGIS wraps parameters with spaces in them in single quotes when passing multivalue parameters. If I run the following script as a toolbox script tool and pass it "a b c" and "abc" as the first parameter, I get the below output import arcpy
SAGIS_Input = arcpy.GetParameterAsText(0)
SAGIS_model_new = SAGIS_Input.split(";")
SAGIS_Count = len(SAGIS_model_new)
for model in SAGIS_model_new:
arcpy.AddMessage(model) Notice the single quotes around the values 'a b c'? You need to strip them off with something like: for model in SAGIS_model_new:
model = model.strip("'")
... View more
12-14-2015
03:30 PM
|
1
|
0
|
2200
|
|
POST
|
To wrap things up, there doesn't seem to be a way of doing this in arcpy (ArcGIS Idea - Add 'AlreadyInitalized' to arcpy.CheckExtension function. ). So I use a try: except: clause in a context manager to do this now: class SAExtension(object):
def __init__(self):
self.name = 'Spatial'
from arcpy.sa import Int
try:
Int(1)
except:
self.checkedout = False
else:
self.checkedout = True
def __enter__(self):
if arcpy.CheckExtension(self.name) == "Available":
arcpy.CheckOutExtension(self.name)
else:
raise ValueError("%s license isn't available" % self.name)
def __exit__(self, *args):
if not self.checkedout:
arcpy.CheckInExtension(self.name)
with SAExtension:
#do some raster analysis
... View more
12-13-2015
04:26 PM
|
1
|
1
|
2577
|
|
POST
|
This doesn't appear to have anything to do with ArcGIS. You might be better asking this question at StackOverflow
... View more
12-01-2015
03:25 PM
|
0
|
2
|
10091
|
|
POST
|
Oh neither am I I didn't know that had a name until Dan Patterson posted How to make mistakes in Python... a useful link
... View more
11-30-2015
07:32 PM
|
2
|
1
|
3796
|
|
POST
|
Ahhh... the good old diaper pattern... Just in case there's some other exceptions waiting to bite you, you could do something like: try:
mxd = arcpy.mapping.MapDocument("CURRENT")
except RuntimeError:
print('Not using ArcMap')
else:
df = arcpy.mapping.ListDataFrames(mxd)[0]
ddLayer = arcpy.mapping.Layer(finalOutdd)
projLayer = arcpy.mapping.Layer(finalOutProj)
arcpy.mapping.AddLayer(df, ddLayer, "TOP")
arcpy.mapping.AddLayer(df, projLayer, "TOP")
... View more
11-30-2015
06:59 PM
|
1
|
3
|
3796
|
|
POST
|
Overusing Private Attributes - I cringe when I think about how I used to do this. The“Diaper Pattern” - as a parent of young children, and as a python scripter I'm all too familiar with blowouts...
... View more
11-26-2015
05:37 PM
|
1
|
0
|
2381
|
|
POST
|
I would remove all references to the pythonaddins module in your python toolbox. It's only for use in a python add in.
... View more
11-24-2015
02:38 PM
|
1
|
0
|
1380
|
|
POST
|
You've got your find string and replacement string in the wrong order. Try: arcpy.CalculateField_management("lyrsdePipeInsp", "Photo1", r'Replace( [Photo1],"M:", "\\vancouver.root.local")',"VB") Or: arcpy.CalculateField_management("lyrsdePipeInsp", "Photo1", r"!Photo1!.replace('M:', r'\\vancouver.root.local')", "PYTHON_9.3")
... View more
11-23-2015
01:52 PM
|
3
|
1
|
4981
|
|
POST
|
Use a Workspace datatype - DEWorkspace You can limit the Workspace types allowed with a parameter filter. Something like: def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="Input GDB",
name="in_gdb",
datatype="DEWorkspace",
parameterType="Required",
direction="Input")
param0.filter.type = "Workspace"
param0.filter.list = ["Local Database"]
return [param0, other params etc...]
... View more
11-23-2015
03:34 AM
|
1
|
0
|
1664
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 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 |