|
POST
|
I'd use a slightly different, more "pythonesque" approach using a list: >>> str = "North: 4479928.51 East: 290941.79"
>>> spam = str.split()
>>> spam
['North:', '4479928.51', 'East:', '290941.79']
>>> x,y = float(spam[1]),float(spam[3])
>>> x
4479928.5099999998
>>> y
290941.78999999998
>>>
... View more
12-02-2011
09:59 AM
|
0
|
0
|
3497
|
|
POST
|
CON should be Con in 10 don't know about the % stuff and dot notation isn't supported as far as I know in 10 Yes, indeed, the new 10.0 Python map algebra does not support the "grid.item" notation (which has always been problematic for parsing expressions back to good-old GRID). The new way to do it is to use the [URL=http://help.arcgis.com/en/arcgisdesktop/10.0/help/009z/009z000000sn000000.htm]Lookup[/URL] tool: Con(Lookup("%hor_vis_rg%","COUNT") >= 23, 1) I believe "%" is model element notation -- like Diane is using the Map Algebra tool inside ModelBuilder, and "hor_vis_rg" is a data element inside the model.
... View more
12-02-2011
09:29 AM
|
1
|
0
|
2187
|
|
POST
|
The Mosaic tool has options to smooth out the borders if they overlap. If the rasters do not overlap, you may have to come up with a more fancy method to make the edges match.
... View more
12-02-2011
09:22 AM
|
0
|
0
|
950
|
|
POST
|
Seems to me a raster solution is a lot more doable. My suggested approach is to make a set of rasters built using the focal statistics function (sum) using increasing buffer sizes. Code the buffer distance in the grid name (this could simply be a sequence number "%n%" in ModelBuilder if you are using iteration). When you're done with this, run Extract Multi-Values To Points using your grid cell centroid points against all your focalsum rasters. The resulting point table will have 15,000 rows and can I think you can easily process the table in Excel from there.
... View more
12-02-2011
09:15 AM
|
0
|
0
|
455
|
|
POST
|
What a great idea! I've needed something like this for a while. Here's my take. I attached a 9.3-compatible version too. def FieldNameMap(tbl, maps):
"""Create a field mappings object to rename, drop, or re-order fields.
Arguments
tbl - input feature class, table, or table view
maps - field names map list (';'-delimited string)
If a field is left out, it will not be included in the field map
Example
import arcpy
Maps = "Shape_Area AREA;BID BID2;AREASQMI AREAMI2"
Mapper = FieldNameMap("temp.dbf", Maps)
# to debug: print out the field mapping
print Mapper.exportToString().replace(";","\n")
# copy table, keeping only renamed fields: AREA, BID2, AREAMI2
arcpy.Merge_management("temp.dbf","temp2.dbf",Mapper)
Author
Curtis Price, U.S. Geological Survey, cprice@usgs.gov
Not reviewed/approved use at your own risk
"""
field_mappings = arcpy.FieldMappings()
mapList = Maps.split(';')
for rec in mapList:
fromName,toName = rec.split()
# create a new field map
field_map = arcpy.FieldMap()
# populate it and add to field_mappings
try:
field_map.addInputField(fc_in, fromName)
field = field_map.outputField
field.name = toName
field_map.outputField = field
field_mappings.addFieldMap(field_map)
except:
raise Exception, "Cannot not map fields (%s) in %s" % (rec,tbl)
return field_mappings
... View more
11-22-2011
09:23 AM
|
0
|
0
|
4630
|
|
POST
|
Chris, did you try: arcpy.env.scratchWorkspace = r"C:\Temp"
junk = arcpy.sa.EucAllocation(roadGrd, "", "", "", "VALUE", "", "")
eucAlocGrd = r"C:\Temp\test.gdb\euc_aloc"
junk.save(eucAlocGrd) # copies "C:\Temp\raster3" to "C:\Temp\test.gdb\euc_aloc" This would (in theory) do the processing using grids and then copy the output over to file gdb format (that is, how it works in 9.3 when you specify fgdb output) . I have been told that (in 9.3, probably same as 10.0) if you set the scratch and current workspace to the same location, the temp grid (say, "raster3") will be created and then renamed (rather than copied) when the tool completes. Not quite what you were looking for, but just as fast: arcpy.env.scratchWorkspace = r"C:\Temp"
arcpy.env.workspace = r"C:\Temp"
junk = arcpy.sa.EucAllocation(roadGrd, "", "", "", "VALUE", "", "")
eucAlocGrd = r"outgrid"
junk.save(eucAlocGrd) # renames "raster3" to "outgrid" If you can, *please* submit test data that reproduces these problems with file gdb rasters to ESRI support! Sometimes it is very difficult for them to fix things unless they have a dataset that reproduces the issue.
... View more
11-09-2011
08:33 AM
|
0
|
0
|
1903
|
|
POST
|
I highly recommend using the Project Raster tool to project one of the rasters to match the other one. Raster analysis works best when the inputs are in the same coordinate system.
... View more
10-19-2011
08:27 PM
|
0
|
0
|
1037
|
|
POST
|
Before you interpolate values from the contours using a tool like Topo To Raster, set the geoprocessing Mask environment to your Hawaii polygons. Areas outside the polygon should not have values. This should work with either single or multipart polygons.
... View more
10-19-2011
08:16 PM
|
0
|
0
|
1238
|
|
POST
|
Which version, 9.2, 9.3 and 10.x all have different syntax to access the shape field properties. I recommend you instead of accessing the centroid this way, take an easier path: use the out of the box Feature To Point tool followed by the Add XY Coordinates tool.
... View more
10-19-2011
08:07 PM
|
0
|
0
|
6261
|
|
POST
|
I think you're looking for the Erase tool. You may not need a Python script to do this. This tool does require and ArcInfo license.
... View more
10-19-2011
07:58 PM
|
0
|
0
|
682
|
|
POST
|
Try:
arcpy.CalculateField_management(test_shapefile_path, "LONDD", "float(!shape.firstpoint!.split()[0])", "PYTHON")
arcpy.CalculateField_management(test_shapefile_path, "LATDD", "float(!shape.firstpoint!.split()[1])", "PYTHON")
... View more
10-19-2011
07:48 PM
|
0
|
0
|
1952
|
|
POST
|
Well, I was able to solve my problem by using t = i.replace("'", "") which removes the ' everywhere allowing the tool to accept the input. But I still find it strange that the TableToTable tool won't accept the input as is with ' around it. This is a problem with the text representation of the parameter. Each entry in the list is quoted to ensure it can be somehow parsed, though if the there was a ';' in any of the inputs I'm thinking it would break the python .split(). A safer way to unpack a list of values is to bypass the string representation using GetParameter() instead of GetParameterAsText. Then instead of a string you get a value table which can then be parsed using the value table object methods: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v000000q1000000 If there's a new arcpy way to do it that's better, someone please chime in!
... View more
10-12-2011
08:10 AM
|
0
|
0
|
686
|
|
POST
|
What I don't quite understand is what my input equivalent to your "Raindrops" input should be. The Cost Path tool requires it to be a raster, but it appears to me that your input -- several raindrops -- is a point layer. Can you clear this up for me? Clearly my knowledge of raster processing is sorely lacking. Many raster tools accept features as well as rasters and convert on the fly (using default raster properties). You can control this on-the-fly rasterizing (cell size etc) using the raster geoprocessing environment.
... View more
10-12-2011
07:45 AM
|
0
|
0
|
4300
|
|
POST
|
I got these two functions working pretty well so I thought I'd share them. These are fairly general purpose, so for example, say you want a string field you could format the results like this (Calculate Field, python): "%4i %2i %5.3f %3i %2i %5.3f " % dd2dms(!LATDD!,!LONDD!)
def dd2dms(dd1,dd2,ndec=6):
"""Convert a decimal degree coordinate pair to a six-tuple of degrees, minutes seconds.
The returned values are not rounded.
Arguments
dd1, dd2 - coordinate pair, in decimal degrees
Example
>>> dd2dms(-74.25,32.1)
(-74, 15, 6.9444444444444444e-05, 32, 6, 2.7777777777778172e-05)
"""
# Author: Curtis Price, http://profile.usgs.gov/cprice
# Disclaimer: Not approved by USGS. (Provisional, subject to revision.)
def ToDMS(dd):
dd1 = abs(float(dd))
cdeg = int(dd1)
minsec = dd1 - cdeg
cmin = int(minsec * 60)
csec = (minsec % 60) / float(3600)
if dd < 0: cdeg = cdeg * -1
return cdeg,cmin,csec
try:
# return a six-tuple
return ToDMS(dd1) + ToDMS(dd2)
except:
raise Exception, "Invalid input"
def dms2dd(deg1,min1,sec1,deg2,min2,sec2):
"""Convert a degrees-minutes seconds coordinate pair to decimal degrees.
The returned values are not rounded.
Arguments
deg1,min1,sec1,deg2,min2,sec2 - DMS coordinate pair (six values)
Example
>>> dms2deg(-74,45,0,34,10,20)
(-74.75, 34.172222222222217)
"""
# Author: Curtis Price, http://profile.usgs.gov/cprice
# Disclaimer: Not approved by USGS. (Provisional, subject to revision.)
def ToDD(deg,min=0,sec=0):
dd = abs(deg) + min / 60.0 + sec / 3600.0
if deg < 0:
dd = dd * -1.0
return dd
try:
return ToDD(deg1,min1,sec1), ToDD(deg2,min2,sec2)
except Exception:
raise Exception, "Invalid input"
... View more
09-29-2011
02:05 PM
|
0
|
0
|
10377
|
|
POST
|
Here's my shot at it:
def dd2dms(dd1,dd2):
"""Convert decimal degree value to a tuple of degrees, minutes seconds.
Argument
dd1, dd2 - value in decimal degrees
Example:
>>> deg2dms(-74.49999)
(-74, 29, 3539.9639999999918)
Author: Curtis Price, http://profile.usgs.gov/cprice
Disclaimer: Not approved by USGS. (Provisional, subject to revision.)
"""
def ToDMS(dd):
deg = int(abs(dd))
min = int((abs(dd) - deg) * 60)
sec = (abs(dd) - (deg - (min / 60.0))) * 3600.0
if dd < 0: deg = deg * -1
return deg,min,sec
try:
# return a six-tuple
return ToDMS(dd1) + ToDMS(dd2)
except:
raise Exception, "Invalid input"
def dms2dd(deg1,min1,sec1,deg2,min2,sec2):
"""Convert degrees, minutes seconds to decimal degrees values.
Argument
deg1,min1,sec1,deg2,min2,sec2 - coordinate pair (2 x 3)
Example
>>> dms2deg(-74,45,0,34,10,20)
(-74.75, 34.172222222222217)
Author: Curtis Price, http://profile.usgs.gov/cprice
Disclaimer: Not approved by USGS. (Provisional, subject to revision.)
"""
def ToDD(deg,min=0,sec=0):
dd = abs(deg) + min / 60.0 + sec / 3600.0
if deg < 0:
dd = dd * -1.0
return dd
try:
return ToDD(deg1,min1,sec1), ToDD(deg2,min2,sec2)
except Exception:
raise Exception, "Invalid input"
... View more
09-29-2011
01:06 PM
|
0
|
0
|
10377
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-11-2021 01:26 PM | |
| 5 | 12-10-2021 04:58 PM | |
| 1 | 02-27-2017 09:30 AM | |
| 2 | 12-04-2023 01:05 PM | |
| 1 | 04-12-2016 10:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-19-2024
12:10 AM
|