POST
|
hi Robert, as described in the help topic, the transform method is an optional parameter(String), which you´ll need to specify. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000007m000000 for example:
in_FC = path to in_FC
out_FC = path to out_FC
install_dir = arcpy.GetInstallInfo()['InstallDir']
outCS = os.path.join(install_dir, r"Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\Northern Hemisphere\WGS 1984 UTM Zone 33N.prj")
transform_method = "MGI_To_WGS_1984_3"
arcpy.Project_management(in_FC, out_FC, outCS, transform_method)
... View more
05-28-2013
06:04 AM
|
0
|
0
|
543
|
POST
|
changed the code a bit to update the shape field of the targetFC as well. works for me if the FCs are point-type.
import arcpy
source = "E:/test.mdb/src"
target = "E:/test.mdb/trg"
# cursor for sourceFC
s_rows = arcpy.SearchCursor(source)
# Dictionary for sourceFCs fields
sDict = {}
# field names of sourceFC/targetFC, excluding Shape and OID
fList = [a.name for a in arcpy.ListFields(source) if a.name not in ("OBJECTID","Shape")]
# fill the sourceFC Dict(OID as key) with dictionaries of its fieldnames/values
for s_row in s_rows:
sDict[s_row.OBJECTID] = dict((k,s_row.getValue(k)) for k in fList)
# get point coordinates from the shape field and put them into the dict
s_pnt = s_row.Shape.getPart()
sDict[s_row.OBJECTID]["GEO"] = (s_pnt.X,s_pnt.Y)
del s_row,s_rows
print sDict
# update cursor for targetFC
t_rows = arcpy.UpdateCursor(target)
for t_row in t_rows:
# compare the current row's field with the corresponding one from the sourceFC-dict
# if values differ, update all target fields with sourceFC-dicts values
if t_row.LASTMODIFIED != sDict[t_row.OBJECTID]["LASTMODIFIED"]:
for fName in fList:
t_row.setValue(fName, sDict[t_row.OBJECTID][fName])
# replace point coordinates of shape field with values from the sourceFC-dict
t_pnt = arcpy.Point(sDict[t_row.OBJECTID]["GEO"][0],sDict[t_row.OBJECTID]["GEO"][1])
t_row.setValue("Shape", t_pnt)
t_rows.updateRow(t_row)
del t_row,t_rows
... View more
04-09-2013
06:19 AM
|
0
|
0
|
529
|
POST
|
like arek said, you have to get the values of your source FC and update the corresponding fields in the target FC. something like this should work (only tested with a small sample of data), or at least help get you started: import arcpy
source = "E:/test.mdb/src"
target = "E:/test.mdb/trg"
# cursor for sourceFC
s_rows = arcpy.SearchCursor(source)
# Dictionary for sourceFC´s fields
sDict = {}
# field names of sourceFC/targetFC, excluding Shape and OID
fList = [a.name for a in arcpy.ListFields(source) if a.name not in ("OBJECTID","Shape")]
# fill the sourceFC Dict(OIDs as keys) with dictionaries of its fieldnames/values
for s_row in s_rows:
sDict[s_row.OBJECTID] = dict((k,s_row.getValue(k)) for k in fList)
del s_row,s_rows
# update cursor for targetFC
t_rows = arcpy.UpdateCursor(target)
for t_row in t_rows:
# compare the current row's field with the corresponding one from the sourceFC-dict
# if values differ, update all target fields with sourceFC-dict´s values
if t_row.LASTMODIFIED != sDict[t_row.OBJECTID]["LASTMODIFIED"]:
for fName in fList:
t_row.setValue(fName, sDict[t_row.OBJECTID][fName])
t_rows.updateRow(t_row)
del t_row,t_rows
... View more
04-08-2013
07:03 AM
|
0
|
0
|
529
|
POST
|
your output contains 2 paths. took the liberty and modified it a bit: import arcpy,os from arcpy import sa arcpy.gp.overwriteOutput=True arcpy.CheckOutExtension("spatial") import glob Output="E:/test/New Folder" Input=glob.glob("E:/test/New Folder/*tif") for i in Input: outfile = "D:/Freelancer/oDesk/Create-ArcPy-Scripts/OutputFiles/" + os.path.split(i)[-1] arcpy.Resample_management(i, outfile, "1000 1000", "BILINEAR")
... View more
04-08-2013
02:27 AM
|
0
|
0
|
136
|
POST
|
Hi Jess, i changed your code a bit (you´ll have to set the output path to where you want it), it should do what you want now: # Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = r"e:\test"
# Set local variables
inMaskData = "rmask.shp"
outFolder = r"e:\test\masked"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Get a list of the rasters in the workspace
rasters = arcpy.ListRasters()
# Loop through the list of rasters
for inRaster in rasters:
# Set the outputname for each output to be the same as the input
outRaster = outFolder + "\\" + inRaster
# Process: Extract by Mask
arcpy.gp.ExtractByMask_sa(inRaster, inMaskData, outRaster)
... View more
04-04-2013
10:46 PM
|
0
|
0
|
1458
|
POST
|
if you just need to convert all the .asc files in one folder and TIF-Rasters are ok, you could try the script below. import os,arcpy, glob
# Path to ascii files
filepath = r"E:\test\ascdirectory"
# Path where to put rasters
outFolder = r"E:\test\ascdirectory\rasters"
ascList = glob.glob(filepath + "/*.asc")
print ascList
for ascFile in ascList:
outRaster = outFolder + "/" + os.path.split(ascFile)[1][:-3] + "tif"
print outRaster
arcpy.ASCIIToRaster_conversion(ascFile, outRaster, "FLOAT")
... View more
03-14-2013
11:31 PM
|
1
|
2
|
668
|
POST
|
not sure if i completely understand, but your script looks like you´re working with layers inside arcmap in the current mxd. If you want to copy selected features of a layer to a new feature class, CopyFeatures will respect the selection: Summary Copies features from the input feature class or layer to a new feature class. If the input is a layer which has a selection, only the selected features will be copied. If the input is a geodatabase feature class or shapefile, all features will be copied. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000035000000
... View more
03-14-2013
08:02 AM
|
0
|
0
|
1772
|
POST
|
as the others before said, you can use the same code you used for a shapefile: # describe the feature layer to access the the selected set
desc = arcpy.Describe(lyr)
# FIDSet will contain the selected features
selectedFids = desc.FIDSet But you will only get a list of values if you have selected some features before running the code.
... View more
03-13-2013
11:14 PM
|
0
|
0
|
1772
|
POST
|
your out_dataset points to a gdb, not a feature classs or table as required. you could try this, which should give each table in the output database the same name it had in the input database. out_dataset = r"E:\Database Project\ACS Estimate 2011\Data\To Database\Seq Tables.gdb" + "\\" + table edit: forgot to make it a raw string.
... View more
03-12-2013
07:21 AM
|
0
|
0
|
244
|
POST
|
the link to your attachment doesn´t work for me: "Invalid Attachment specified. If you followed a valid link, please notify the administrator"
... View more
03-12-2013
06:38 AM
|
0
|
0
|
244
|
POST
|
Hi Mike, you´ll have to use the ToolValidator Class to do this: for a sample tool with 3 parameters where you can first select a Layer then select the field and get the chosen field´s values: FC (datatype: Layer) Field (datatype: Field) Value (datatype: String) on the validation tab change the validator class code: class ToolValidator: """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog.""" def __init__(self): """Setup arcpy and the list of tool parameters.""" import arcpy self.params = arcpy.GetParameterInfo() def initializeParameters(self): """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" self.params[1].parameterDependencies = [0] # set the parameter dependency for Field to the FC return def updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parmater has been changed.""" import arcpy FC = self.params[0].value fldName = self.params[1].value vList = [] #use a cursor to get values of selected field into vList rows = arcpy.SearchCursor(FC) for row in rows: fldVal = str(row.getValue(fldName)) vList.append(fldVal) self.params[2].filter.list = vList #fill the Values Parameter with the selected field´s values return def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return
... View more
03-05-2013
10:01 PM
|
1
|
1
|
1194
|
POST
|
Hi David, if you´re looking for the row/column of a single point it should be: Column = (CurrentXcoordinate - XLLcenter) / Cellsize Row = (nrows -1) - (CurrentYcoordinate - YLLcenter) / Cellsize
... View more
02-12-2013
10:35 PM
|
0
|
0
|
779
|
POST
|
If you know the parameters (extent, cellsize, nodata...) of the xyz files you can try something like this: http://forums.arcgis.com/threads/64615-Bathymetry-.xyz-data-to-raster?p=239543&viewfull=1#post239543 or this from arcscripts: http://arcscripts.esri.com/details.asp?dbid=12876
... View more
02-04-2013
12:24 AM
|
0
|
0
|
1318
|
POST
|
Do you have to use a Point FeatureClass? I think converting the xyz files to a raster directly could be faster.
... View more
02-03-2013
10:38 PM
|
0
|
0
|
1318
|
POST
|
the code works for me as well. i just said that i would also be very interested in a more/only numpy-based approach.
... View more
12-12-2012
03:28 AM
|
0
|
0
|
273
|
Title | Kudos | Posted |
---|---|---|
1 | 03-05-2013 10:01 PM | |
1 | 03-14-2013 11:31 PM | |
1 | 09-15-2011 10:30 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|