|
POST
|
Gracias Luis, Just found that what was going on: The "AreaFilter" field data type on the attribute table was "Double"; that matches the data type for the parameter within the tool properties dialogue box (see image) (there is no "Float" option). Well, apparently python doesn't like that. I created a new "Float" Area field and used it in the script instead of AreaFilter. Now it works. I think that the fact that there is no "Float" option in the Data Type python tool may lead to confusion. Cheers
... View more
11-12-2014
03:25 AM
|
0
|
0
|
2491
|
|
POST
|
Thanks Jake. Yes, I had already try that. I don't quite understand why it's not working. Cheers
... View more
11-12-2014
02:06 AM
|
0
|
4
|
2491
|
|
POST
|
Hi, I'm trying to use the GetParameterAsText() for user input. When I use a value instead, it works fine but not with GetParameterAsText() Any help will be greatly appreciate. NOT WORKING WORKING
AreaFilter = arcpy.GetParameterAsText(0)
cur = arcpy.UpdateCursor(outFeatureAREA)
for row in cur:
if row.F_AREA <= AreaFilter:
cur.deleteRow(row)
cur.updateRow(row)
del row
del cur
... View more
11-11-2014
07:51 AM
|
0
|
8
|
3765
|
|
POST
|
Thank you Neil anyway. Thanks for your suggestion Kim. I wonder if you can do that in 10.0 as I cannot find the copy_and_modify button (just modify) as well as the option of adding a false origin. Cheers
... View more
02-12-2014
02:31 AM
|
0
|
0
|
2904
|
|
POST
|
Thank you for your reply Neil. I had seen that post in the ArcPy Café page already. I think that is meant for 10.1 It doesn't work for 10.0 The reason I need to shift 360 is to make the world "wider" (see image of the feature layer to be shifted East; in fact I need to shift one part +360 (East) and another -360 (West)) as a previous step to run Euclidean Distance so I can get a continuous raster layer instead of having a sharp end where both edges meat. The result is then clipped to the appropriate extent. As I said, it is easy enough to use the Move functionality within an edit session but I need to include this process as a part of a larger python script. [ATTACH=CONFIG]31308[/ATTACH] In the image, the Feature layer in red needs to be shifted 360 East and the feature layer in blue 360 West Cheers
... View more
02-11-2014
03:29 AM
|
0
|
0
|
2904
|
|
POST
|
Hi, I need to horizontally shift a Polyline feature class (clip1diss) (just one raw) 360 degrees East (deltaX = 360). It would be the equivalent as to "Move" in an Edit session in ArcMap but I cannot quite find the appropriate Python code to perform the same operation. Running 10.0 Any help would be greatly appreciate it. Many thanks
... View more
02-11-2014
12:58 AM
|
0
|
8
|
3023
|
|
POST
|
Hi Mark, I applied your procedure on the polyline feature class. it works very well. Many thanks
... View more
02-10-2014
01:14 AM
|
0
|
0
|
2000
|
|
POST
|
Thanks Mark, I get a bit confused when you say "Run your analysis". Would it make sense to do what you're suggesting on the source polyline country layer (attached image) and then run the Euclidean distance tool? Cheers
... View more
02-07-2014
06:43 AM
|
0
|
0
|
2000
|
|
POST
|
Hi, I need to do some euclidean distance on a global scale. I find that there is no a natural continuation at the edges due to the Maximum distance option set to default. I've tried with different values always with the same output. I wonder if someone can suggest a way round this so I can get a continuous raster dataset instead of a sharp differentiation at the edges. Please see images attached. Many thanks [ATTACH=CONFIG]31207[/ATTACH] [ATTACH=CONFIG]31208[/ATTACH] [ATTACH=CONFIG]31209[/ATTACH]
... View more
02-06-2014
11:58 PM
|
0
|
3
|
3050
|
|
POST
|
Hi, I wonder if anybody knows of the right conditional statement to be used in Raster Calculator to set to "Null" (NoData) the raster cells of Raster 1 that coincide (overlap) with cells in Raster 2. Please see images: Raster 1 in red Raster 2 in blue The areas in red that coincide with the areas in blue should become "Null". Using ArcView10 Many thanks [ATTACH=CONFIG]30569[/ATTACH]
... View more
01-16-2014
05:50 AM
|
0
|
2
|
2925
|
|
POST
|
Hi, I'm trying to find out how to permanently save a raster using a workspace variable + Raster name with little success so far. In the Help it only shows how to do it hard-coding the output. Please see code below. import arcpy import string from arcpy import env arcpy.env.overwriteOutput=True from arcpy.sa import * arcpy.CheckOutExtension("Spatial") # Variables OutLocation = arcpy.GetParameterAsText(0) Raster1 = arcpy.Raster(arcpy.GetParameterAsText(1)) Raster2 = arcpy.Raster(arcpy.GetParameterAsText(2)) # Calculation and save CDF = Raster1 * Raster2 OutFile = "CDF" FullOutFile = OutLocation + OutFile # For example: r"Q:\LFP_GLOBAL\OUTPUT.gdb\CDF" CDF.save(FullOutFile) Any help would be greatly appreciated. Many thanks
... View more
12-27-2013
05:27 AM
|
0
|
2
|
2717
|
|
POST
|
Hi, Just in case anyone's interested I just found out where the problem was: In the calculation of Parameter 5 (CDF) NPP is used. NPP is the output of Parameter 4 and the result of Mosaic to New Raster. As far as I can see NPP is not quite recognised as a raster object within the Parameter 5 calculation (not really sure why). So I added "arcpy.Raster" in front of the "arcpy.MosaicToNewRaster_management" like this: NPP = arcpy.Raster(arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")) (The other option is to just add Raster in front of (NPP) in the CDF calculation equation). Now it works. Thanks for your help anyway.
... View more
12-27-2013
01:20 AM
|
0
|
0
|
4734
|
|
POST
|
Hi there, Thanks a lot for your comments. Still pretty much lost though... Please see below two versions of the same code. I'm just changing the calculation in "Calculation of Parameter 5". CODE A works. CODE B does NOT. In CODE B I'm getting the "Operand Error". Any ideas? CODE A: import arcpy
import string
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set the output location and extent
OutLocation = arcpy.GetParameterAsText(0)
arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)
# Input strings, variables and mask
StageAge = arcpy.GetParameterAsText(1)
BSS = arcpy.Raster(arcpy.GetParameterAsText(2))
InputLatitude = arcpy.Raster(arcpy.GetParameterAsText(3))
InputZ = arcpy.GetParameterAsText(4)
InputCountrylines = arcpy.GetParameterAsText(5)
NPPEquation = arcpy.GetParameterAsText(6)
CDFEquation = arcpy.GetParameterAsText(7)
env.mask = InputZ
# Calculate latitude North/South and offshore distance; also set the "0" values from Offshoredistance and Bathymetry to "1"
LatNorth = Con((InputLatitude > 0),(InputLatitude))
LatSouth = Con((InputLatitude < 0),(InputLatitude))
Offshoredistancemin0 = EucDistance(InputCountrylines, "", 0.5, "")
Offshoredistance = Con((Offshoredistancemin0 == 0),1,(Offshoredistancemin0))
InputZ1 = Con((InputZ == 0),1,(InputZ))
ZforCDF = Con((InputZ1) >50, (InputZ1))
# Calculation of Parameter 3 - Background Total Organic Carbon (TOC)
range1 = Con(((BSS) < 0.0378), (BSS))
range1phi = Con((range1), 6.11)
range2 = Con(((BSS) >= 0.0378) & ((BSS) <= 0.47), (BSS))
range2mm = 0.0593-(1.7714*(range2))+(18.7109*Power((range2),2))-(22.7289*Power((range2),3))
range2phi = -3.3219*Log10((range2mm))
range3 = Con(((BSS) > 0.47), (BSS))
range3mm = 0.8381 + (1.2188*(range3)) - (0.0007*Power((range3),2))
range3phi = -3.3219*Log10((range3mm))
GrainSizephi = arcpy.MosaicToNewRaster_management([(range1phi), (range2phi), (range3phi)], OutLocation, (StageAge) + "_Grain_Size_phi", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")
# Calculation of Parameter 4 - Net Primary Productivity (NPP).
if NPPEquation == "Min NPP":
rasterNorth = (-1.9875 * (LatNorth) + 194)
rasterSouth = (2.3377 * (LatSouth) + 200)
NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")
# Calculation of Parameter 5 - Carbon Delivery Flux (CDF).
if CDFEquation == "1. Suess 1980":
CDF = (NPP * ZforCDF / 100) * 4
CDF.save(r"Q:\LFP_GLOBAL_Python\OUTPUT.gdb\CDF")
CODE B: import arcpy
import string
from arcpy import env
arcpy.env.overwriteOutput=True
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
# Set the output location and extent
OutLocation = arcpy.GetParameterAsText(0)
arcpy.env.extent = arcpy.Extent(-180.0, -90.0, 180.0, 90.0)
# Input strings, variables and mask
StageAge = arcpy.GetParameterAsText(1)
BSS = arcpy.Raster(arcpy.GetParameterAsText(2))
InputLatitude = arcpy.Raster(arcpy.GetParameterAsText(3))
InputZ = arcpy.GetParameterAsText(4)
InputCountrylines = arcpy.GetParameterAsText(5)
NPPEquation = arcpy.GetParameterAsText(6)
CDFEquation = arcpy.GetParameterAsText(7)
env.mask = InputZ
# Calculate latitude North/South and offshore distance; also set the "0" values from Offshoredistance and Bathymetry to "1"
LatNorth = Con((InputLatitude > 0),(InputLatitude))
LatSouth = Con((InputLatitude < 0),(InputLatitude))
Offshoredistancemin0 = EucDistance(InputCountrylines, "", 0.5, "")
Offshoredistance = Con((Offshoredistancemin0 == 0),1,(Offshoredistancemin0))
InputZ1 = Con((InputZ == 0),1,(InputZ))
ZforCDF = Con((InputZ1) >50, (InputZ1))
# Calculation of Parameter 3 - Background Total Organic Carbon (TOC)
range1 = Con(((BSS) < 0.0378), (BSS))
range1phi = Con((range1), 6.11)
range2 = Con(((BSS) >= 0.0378) & ((BSS) <= 0.47), (BSS))
range2mm = 0.0593-(1.7714*(range2))+(18.7109*Power((range2),2))-(22.7289*Power((range2),3))
range2phi = -3.3219*Log10((range2mm))
range3 = Con(((BSS) > 0.47), (BSS))
range3mm = 0.8381 + (1.2188*(range3)) - (0.0007*Power((range3),2))
range3phi = -3.3219*Log10((range3mm))
GrainSizephi = arcpy.MosaicToNewRaster_management([(range1phi), (range2phi), (range3phi)], OutLocation, (StageAge) + "_Grain_Size_phi", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")
# Calculation of Parameter 4 - Net Primary Productivity (NPP). Check the NPP Equation Name and follow the appropiate branch
if NPPEquation == "Min NPP":
rasterNorth = (-1.9875 * (LatNorth) + 194)
rasterSouth = (2.3377 * (LatSouth) + 200)
NPP = arcpy.MosaicToNewRaster_management([(rasterNorth), (rasterSouth)], OutLocation, (StageAge) + "_MinNPP", "", "32_BIT_FLOAT", "", "1", "LAST", "FIRST")
# Calculation of Parameter 5 - Carbon Delivery Flux (CDF). Check the CDF Equation Name and follow the appropiate branch
if CDFEquation == "1. Suess 1980":
CDF = Con((ZforCDF >= 50) & (ZforCDF < 100), NPP * 2, NPP * 4)
CDF.save(r"Q:\LFP_GLOBAL_Python\OUTPUT.gdb\CDF")
... View more
12-26-2013
11:18 AM
|
0
|
0
|
4733
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-06-2015 05:13 AM | |
| 1 | 11-09-2015 01:25 AM | |
| 1 | 11-12-2014 05:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-12-2022
09:52 AM
|