|
POST
|
OK, now i know what you trying to do. Not sure this is the easiest way, but got no better idea. My proposition is: 1) Create empty mxd file. - this is manual part - one mxd is enough. Loop for each lyr: 2) Add lyr file to data frame in this mxd. 3) Read name of grouplayer from ListLayer in mxd. 4) Use AddLayerToGroup with data you want to use and group name read in previous point. 5) Save layer from mxd to lyr (function save() or saveACopy() on layer object from mxd). 6) Remove all layers from mxd That's only idea I have. Maybe someone know easiest way. Cheers Arek
... View more
01-10-2013
04:22 AM
|
0
|
0
|
1127
|
|
POST
|
Hi, What does "add additional data layers to an existing layer (.lyr)" stands for? You want to chage featureclass, definition query, addaditional data to GroupLayer lyr, or what? Cheers Arek
... View more
01-09-2013
12:49 AM
|
0
|
0
|
1127
|
|
POST
|
Hi, Yes, error shows up because You don't have licence for this tool (Advanced is needed). I think simplest workaround would be using data access search cursor with Shape@centroid and insert cursor to create points. Cheers. Arek
... View more
12-10-2012
01:10 AM
|
0
|
0
|
341
|
|
POST
|
Code was tested before I submitted it, and worked fine. Maybe problem lays somewhere else. Have you checked paths to files? Does python window in arcmap shows any error message when you activate tool or using it? Regards.
... View more
11-29-2012
10:26 PM
|
0
|
0
|
1130
|
|
POST
|
Not sure what you mean by saying "import variables X Y". You want to prepare a list or read them from file or something. If list is ok for you, then code below should work (assume that coords are floats). If you want to read them from file the simply prepare list from text file before for loop:
points = []
f = open('C:\\coords.txt', 'r')
for line in f.readlines():
x, y = [coord.strip() for coord in line.split(';')] #suppose coords are delimited with semicolons
points.append((float(x), float(y)))
f.close() from osgeo import ogr
LandUse = ogr.Open("C:\\Python26\\ArcGIS10.0\\landuse shpfile (polygon)\\landuse.shp")
lyr = LandUse.GetLayerByName("landuse data_ypan")
lyr.ResetReading()
points = [(x1,y1), (x2, y2),...,(xn, yn)]
for coords in points:
point = ogr.CreateGeometryFromWkt("POINT(%f %f)" % coords)
for feat in lyr:
geom = feat.GetGeometryRef()
if geom.Contains(point):
sm = feat.GetField(feat.GetFieldIndex("Land_Group"))
print sm Cheers Arek
... View more
11-29-2012
03:32 AM
|
0
|
0
|
527
|
|
POST
|
Hi, Corrected code for onRectangle below. functions from management toolbox returns nothing so assignment like: ras1 = arcpy.Clip_management What is more function arcpy.Clip_management takes one string as second argument, not 4 floats. def onRectangle(self, rectangle_geometry): extent = rectangle_geometry arcpy.Clip_management('D:\\DATA\\temp\\trans.tif', "%f %f %f %f" % (extent.XMin, extent.YMin, extent.XMax, extent.YMax), 'ras1', "#", "#", "NONE") arcpy.RefreshActiveView() Cheers. Arek
... View more
11-28-2012
11:50 PM
|
0
|
0
|
1130
|
|
POST
|
Hi, You can read XY of first cell (from raster extent) of raster and cell size, then having row and column number of cell compute coordinates of cell center. http://resources.arcgis.com/en/help/main/10.1/index.html#//018z00000051000000 Cheers Arek
... View more
11-26-2012
05:06 AM
|
0
|
0
|
1103
|
|
POST
|
I am attempting to create a python script that will accomplish a number of objectives. 1: I need it to select crimes based off of temporal attributes (time and date of crime, perhaps the most common ones) and the type of offenses 2: I need it to output the data in choropleth fashion based off of census blocks This is for Old Dominion University in Norfolk, Va with approx. a 5 mile radius around it. This either needs to become a new shapefile or a new column in the census blocks layer. Cool 🙂 And where's the question? Cheers, Arek 🙂
... View more
11-26-2012
04:56 AM
|
0
|
0
|
349
|
|
POST
|
I think best option would be creating some python tool. There is tool that allows to execute SQL via SDE connection: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z00000021000000.htm if not, I'm sure there are some other libraries for python that allows calling SQLServer stored procedure in Python. Incorporating such solution should be quite easy. Regards Arek
... View more
11-15-2012
10:49 PM
|
0
|
0
|
1357
|
|
POST
|
Shape.Area and Schape.Length are parts of st_geometry definition, if you're using sdo_geometry type geometry is stored in other tables in oracle, so this fields will stay empty. Cheers Arek
... View more
11-15-2012
10:38 PM
|
1
|
0
|
2092
|
|
POST
|
Hi, I don't understand why you want to do this in ToolValidator? Why not in script itself? Cheers. Arek
... View more
11-15-2012
10:31 PM
|
0
|
0
|
1012
|
|
POST
|
Hi, You may try to count it having raster extension, and cell size (from arcpy.Raster() class attributes) you can calculate center of any cell in raster (multiply cell size by numbers of rows and cols and add to coords of lower left corner) . With that calculating distance between point and raster cell should be piece of cake. Regards Arek
... View more
11-14-2012
03:57 AM
|
0
|
0
|
497
|
|
POST
|
AddLayer takes 3 arguments:
AddLayer (data_frame, add_layer, {add_position})
where data_frame must be instance of arcpy.mapping.DataFrame, add_layer must be instance of arcpy.Layer. All you have to do is define data frame of mxd and create arcpy.Layer()'s from paths so:
TemplateLayers=(r"\\...\TemplateLayers.txt")
lyrDict={}
with open (TemplateLayers) as f:
for line in f:
key,val=line.split(",")
lyrDict[key]=val
f.close()
print lyrDict
mxd = arcpy.mapping.MapDocument('path\\to\\mxd.mxd')
df = arcpy.mapping.ListDataFrames(mxd)[0]
#Step 2: Pull the layers into the MXD at the bottom of the data frame from the dictionary.
for val in lyrDict.values():
arcpy.mapping.AddLayer(df,arcpy.Layer(val),"Bottom")
That should do. Regards Arek
... View more
11-14-2012
03:33 AM
|
0
|
0
|
617
|
|
POST
|
Hi, If you have all your graphs in .grf files in one folder you can simply create list of them with os.listdir(path).
import os
path = 'c:\\temp'
grf_list = [file for file in os.listdir(path) if file.split('.')[-1] == 'grf']
for grf in grf_list:
...do something...
Regards.
... View more
11-08-2012
10:41 PM
|
0
|
0
|
541
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-05-2022 08:01 AM | |
| 1 | 03-29-2023 12:37 AM | |
| 2 | 08-06-2013 05:40 AM | |
| 1 | 11-15-2012 10:38 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-29-2023
03:19 PM
|