|
POST
|
This is possible with Python and Basic license, although untested for large datasets (I did run this against 1000+ points and it was fine). First step is to dissolve all roads into a single feature, although you could loop through them with added code. >>> points = "points_select" # points layer
... sr = arcpy.Describe(points).spatialReference # get CRS
... lines = "roads_select" # roads feature class containing single, merged feature for all roads
... out_lines = [] # output list
... line_geom = [i[0] for i in arcpy.da.SearchCursor(lines,'SHAPE@',spatial_reference=sr)] # the road feature
... with arcpy.da.SearchCursor(points,'SHAPE@') as cursor: # loop through points
... for row in cursor:
... end = line_geom[0].queryPointAndDistance(row[0])[0].centroid # get nearest point on line
... start = row[0].centroid
... out_lines.append(arcpy.Polyline(arcpy.Array([start,end]),sr)) # connect the dots and add to line list
... arcpy.CopyFeatures_management(out_lines,r'in_memory\out_lines') # write line list to disk
... View more
08-18-2016
04:29 PM
|
2
|
0
|
4168
|
|
POST
|
Okay, it's just that the picture of your model shows Append flowing into Dissolve, but unless your two layer name variables are equal, that's not what your script is doing. Also, the path in the Append tool is enclosed by double, then single quotes, which is non-standard. I'm not sure if that causes any problems, just not sure why it was interpreted that way.
... View more
08-18-2016
10:09 AM
|
1
|
2
|
1968
|
|
POST
|
Double-check your layer names/variables (we can't see that part of your script): ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS vs. ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS__2_
... View more
08-18-2016
10:01 AM
|
1
|
4
|
1968
|
|
POST
|
You can get at this with Python: >>> fc = 'points' # feature class/layer
... field = 'Id' # field to inspect
... start = 0 # first value
... stop = 25 # last value
... step = 1 # increment value
... present_values = [i[0] for i in arcpy.da.SearchCursor(fc,field)] # load present values to list
... missing_values = [i for i in range(start,stop,step) if i not in present_values] # compare present values to possible values
... print missing_values # print list, or do some thing with values
...
[0, 9, 15, 16, 21, 22, 23, 24]
... View more
08-17-2016
08:47 AM
|
1
|
0
|
833
|
|
POST
|
Try initializing 'inside' to None just inside the p loop: for p in points:
inside = None edit: compare your indentation to Xander's at 'while not inside'. It's different and is responsible for your problem.
... View more
08-16-2016
01:58 PM
|
1
|
1
|
2244
|
|
POST
|
You would change the z-factor if your XY coordinates are in different units than the Z. For example, if your data is in a horizontal projection using feet and the vertical datum is in meters. The tool would interpret a 1 x 1 x 1 cube as 1 cubic feet, when it should actually be 1' x 1' x 1m or 1' x 1' x 1' * 3.28084 (the z-factor). I assume you would input 3.28084, although it may be 1/3.28084. Luckily, I work in Canada, where the only unit is meter (or metre!).
... View more
08-16-2016
10:58 AM
|
0
|
2
|
4013
|
|
POST
|
Don't worry about the LOCK files. The sbx isn't a mandatory file (see here). I'd try making a copy and deleting everything but the mandatory files and see what happens. Also, try opening in different software (e.g. QGIS), which can sometimes open otherwise corrupt files.
... View more
08-16-2016
10:03 AM
|
1
|
0
|
4649
|
|
POST
|
Invalid Topology [Topoengine error.] Try running Check Geometry and see if it returns any errors for your problem feature class.
... View more
08-16-2016
09:42 AM
|
0
|
1
|
1991
|
|
POST
|
Code in question (I believe you do need a field called 'count', although I'm not familiar with the old cursors, anymore): import sys, arcpy
#InFeatClass = sys.argv[1]
#OutFeatClass = sys.argv[2]
InFeatClass = "S:/GIS_Public/GIS_Data/DefaultGDB/Default.gdb/tempUnitsperParcel"
OutFeatClass = "S:/GIS_Public/GIS_Data/DefaultGDB/Default.gdb/tempUnitsperParcel4"
# overwriting output is ok.
arcpy.env.overwriteOutput = True
# copy the count = 1 features to create a new feature class, saves having to do
# new feature class, copy spatial reference and fields..
arcpy.Select_analysis(InFeatClass,OutFeatClass,"UNIT_NUMBE = 1")
# setup cursor objects - search the source, isert the destination
InsCur = arcpy.InsertCursor(OutFeatClass)
SrchCur = arcpy.SearchCursor(InFeatClass,"UNIT_NUMBE > 1")
# get the list of fields to copy
FieldList = arcpy.ListFields(InFeatClass,"*")
NoCalcFields = ["FID","OBJECTID","SHAPE"]
for InRow in SrchCur:
# create a range and then iterate over it
# inserting a new row for each count
CountRange = range(InRow.count)
for indx in CountRange:
newRow = InsCur.newRow() # create a new (empty) feature
# copy values from the source to the destination
for ThisField in FieldList:
if ThisField.name.upper() not in NoCalcFields:
newRow.setValue(ThisField.name,InRow.getValue(ThisField.name))
# copy the shape
newRow.setValue("SHAPE",InRow.getValue("SHAPE"))
# Store it
InsCur.insertRow(newRow)
... View more
08-15-2016
03:25 PM
|
2
|
0
|
1879
|
|
POST
|
I'm sure this could use some refinement, but I think is approximately what you're after: >>> aa = "12NESW3SESE"
... prev_type = aa[0].isdigit()
... list_1 = []
... cur_word = ''
... for char in aa:
... if char.isdigit() == prev_type:
... cur_word += char
... else:
... list_1.append(cur_word)
... cur_word = char
... prev_type = char.isdigit()
... list_1.append(cur_word)
... print list_1
... list_2 = []
... for i in range(0,len(list_1),2):
... list_2.append(list_1[i+1] + ';' + list_1)
... print list_2
... final_list = ','.join(list_2)
... print final_list
...
['12', 'NESW', '3', 'SESE']
['NESW;12', 'SESE;3']
NESW;12,SESE;3
... View more
08-10-2016
02:28 PM
|
1
|
3
|
3035
|
|
POST
|
You would get the value using a da.SearchCursor, then print the value.
... View more
08-08-2016
09:52 AM
|
1
|
0
|
3433
|
|
POST
|
Are you wondering how to print anything to the shell window, or specifically how to get the value from a GDB table?
... View more
08-08-2016
09:42 AM
|
0
|
2
|
3433
|
|
POST
|
There are many ways to do this, including: - Dissolve (collapse lines into one feature) - Summary Statistics (sum all length) - da.SearchCursor (add lengths, feature by feature) It will depend on exactly what form you want the output to take (feature class, table, just a number stored in a python variable, etc.).
... View more
08-05-2016
01:30 PM
|
1
|
3
|
3433
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM | |
| 2 | 07-16-2020 11:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|