|
POST
|
See the third example on this page, which uses if-then logic in a code block: Calculate Field—Help | ArcGIS for Desktop
... View more
07-27-2016
03:04 PM
|
1
|
0
|
1428
|
|
POST
|
Although I can't vouch for it, this tool promises to do it: http://www.arcgis.com/home/item.html?id=f3d91b8f852042e289e09a7ec8342431 Other than that, given some Python knowledge, you can somewhat easily write a Python script that will do it for you, but I suppose that's what the tool authors already did.
... View more
07-27-2016
02:52 PM
|
1
|
0
|
3044
|
|
POST
|
What do I need to do to find an accurate / trustworthy length measurement? And after that what settings can be used to calculate areas? You should only start measuring length/area once everything (data and data frame) are in a projected coordinate system. As a compromise projection, UTM distorts both distance and area, so technically you should measure distances using an appropriate equidistant CRS, and areas using an appropriate equal area CRS, but most people use UTM for convenience. This doesn't answer why this is happening for you, but if you always do your measurements on projected data, you should be fine. edit: I'll just call over Melita Kennedy, because she can explain this better than anyone I know.
... View more
07-27-2016
01:45 PM
|
1
|
1
|
7355
|
|
POST
|
Just some quick clarification: - you're talking about the scale bar that came through on the original map, not an ArcMap layout scale bar, correct? - I assume you've overlaid your georeferenced map over some known correct data to confirm that your georeferencing matches reality. - Have you checked the map for fine print regarding scale (e.g. "scale only applies to such-and-such a latitude") or does it have a variable scale bar?
... View more
07-27-2016
11:52 AM
|
1
|
4
|
7355
|
|
POST
|
As a start: ArcGIS 10.3.x for Desktop system requirements—Help | ArcGIS for Desktop
... View more
07-27-2016
09:36 AM
|
1
|
0
|
998
|
|
POST
|
Have you inspected the dBase files within ArcGIS? Possibly a problem in the files themselves?
... View more
07-26-2016
02:46 PM
|
0
|
12
|
3420
|
|
POST
|
Did you forget to include a real path? path=r'path'
... View more
07-26-2016
02:40 PM
|
0
|
14
|
3420
|
|
POST
|
Code like this takes a few hours to put together. I hope I can count on the end user to spend a couple minutes making it fit their system.
... View more
07-26-2016
02:25 PM
|
2
|
0
|
2548
|
|
POST
|
I just happened to be working on this very code block and noticed the exact same thing. If you copy it into the Python window in ArcMap (where it was made), it goes in smoothly, but if you try to edit it in an IDE, the ... are problematic. As Adrian suggested, I replaced all '... ' with '' (blank) to remove them. Here's the updated code, but I'm not sure what the best code use advice would be. lines = 'a_line' # line feature class
sr = arcpy.Describe(lines).spatialReference # spatial reference
new_polys = []
new_scratch_polys = []
new_lines = []
buffers = []
max_buff = 50 # buffer at line start
min_buff = 10 # buffer at line end
with arcpy.da.SearchCursor(lines,'SHAPE@',spatial_reference=sr) as cursor: # loop through lines
for row in cursor:
prev_buff = None
for part in row[0]:
for pnt in part:
cur_rad = ((max_buff-min_buff) * (1-row[0].measureOnLine(pnt,True))) + min_buff # calc current proportional buffer size
cur_buff = arcpy.PointGeometry(pnt,sr).buffer(cur_rad) # create buffer geometry
new_poly_array = arcpy.Array()
if prev_buff: # if at least second vertex
cur_poly = cur_poly.union(cur_buff) # add buffer to cumulative geometry
c1 = prev_pnt # previous point center
c2 = pnt
r1 = prev_rad
r2 = cur_rad
dx = c2.X - c1.X
dy = c2.Y - c1.Y
dr = r2 - r1
d = math.sqrt(math.pow(dx,2)+math.pow(dy,2))
X = dx/d
Y = dy/d
R = dr/d
ks = [1,-1]
for k in ks:
a = (R*X)-((k*Y)*math.sqrt(1-math.pow(R,2)))
b = -((R*Y)+((k*X)*math.sqrt(1-math.pow(R,2))))
c = r1 - (a*c1.X) + (b*c1.Y)
tan_x1 = c2.X-10000
tan_x2 = c2.X+10000
tan_y1 = -((((-a)*(tan_x1))-c)/(b))
tan_y2 = -((((-a)*(tan_x2))-c)/(b))
new_line = arcpy.Polyline(arcpy.Array([[arcpy.Point(tan_x1,tan_y1),arcpy.Point(tan_x2,tan_y2)]]),sr) # create line
new_lines.append(new_line)
if k > 0:
new_poly_array.add(new_line.intersect(prev_buff,1).centroid) # find intersections
new_poly_array.add(new_line.intersect(cur_buff,1).centroid) # find intersections
else:
new_poly_array.add(new_line.intersect(cur_buff,1).centroid) # find intersections
new_poly_array.add(new_line.intersect(prev_buff,1).centroid) # find intersections
new_rect = arcpy.Polygon(new_poly_array,sr) # make polygon from intersections
new_scratch_polys.append(new_rect) # add rectangle to scratch geometry
cur_poly = cur_poly.union(new_rect) # add rectangle to cumulative geometry
else:
cur_poly = cur_buff # add buffer to cumulative geometry
prev_rad = cur_rad #remember values
prev_pnt = pnt
prev_buff = cur_buff
buffers.append(prev_buff)
new_polys.append(cur_poly) # add cumulative geometry to list
arcpy.CopyFeatures_management(buffers,r'in_memory\buffers') # write outputs
arcpy.CopyFeatures_management(new_scratch_polys,r'in_memory\scratch_polys')
arcpy.CopyFeatures_management(new_lines,r'in_memory\lines')
arcpy.CopyFeatures_management(new_polys,r'in_memory\polys')
... View more
07-26-2016
01:47 PM
|
1
|
2
|
2548
|
|
POST
|
I'd go with Python, too, although you can simplify it down to: >>> fc = 'points' # feature class
... sr = arcpy.Describe(fc).spatialReference # spatial reference
... lines = [] # output line list
... geoms = [i[0] for i in arcpy.da.SearchCursor(fc,'SHAPE@',spatial_reference=sr)] # point geometries
... for geom1 in geoms: # loop through points
... for geom2 in geoms: # compare to points
... if not geom1.equals(geom2): # if not the same
... lines.append(arcpy.Polyline(arcpy.Array([[geom1.centroid,geom2.centroid]]),sr)) # create line
... arcpy.CopyFeatures_management(lines,r'in_memory\lines') # output to feature class Of course, this removes the feature of a line ID.
... View more
07-26-2016
10:18 AM
|
1
|
0
|
3782
|
|
POST
|
I assume the link in Dan's link is more polished than this, but it caught my interest, and here's the Python code I came up with. Basically, it creates vertex-dependent buffers and trapezoids between the buffers. Math for calculating tangent lines to buffers from here: >>> lines = 'a_line' # line feature class
... sr = arcpy.Describe(lines).spatialReference # spatial reference
... new_polys = []
... new_scratch_polys = []
... new_lines = []
... buffers = []
... max_buff = 50 # buffer at line start
... min_buff = 10 # buffer at line end
... with arcpy.da.SearchCursor(lines,'SHAPE@',spatial_reference=sr) as cursor: # loop through lines
... for row in cursor:
... prev_buff = None
... for part in row[0]:
... for pnt in part:
... cur_rad = ((max_buff-min_buff) * (1-row[0].measureOnLine(pnt,True))) + min_buff # calc current proportional buffer size
... cur_buff = arcpy.PointGeometry(pnt,sr).buffer(cur_rad) # create buffer geometry
... new_poly_array = arcpy.Array()
... if prev_buff: # if at least second vertex
... cur_poly = cur_poly.union(cur_buff) # add buffer to cumulative geometry
... c1 = prev_pnt # math starts here. See: Tangent lines to circles
... c2 = pnt
... r1 = prev_rad
... r2 = cur_rad
... dx = c2.X - c1.X
... dy = c2.Y - c1.Y
... dr = r2 - r1
... d = math.sqrt(math.pow(dx,2)+math.pow(dy,2))
... X = dx/d
... Y = dy/d
... R = dr/d
... ks = [1,-1]
... for k in ks:
... a = (R*X)-((k*Y)*math.sqrt(1-math.pow(R,2)))
... b = -((R*Y)+((k*X)*math.sqrt(1-math.pow(R,2))))
... c = r1 - (a*c1.X) + (b*c1.Y)
... tan_x1 = c2.X-10000
... tan_x2 = c2.X+10000
... tan_y1 = -((((-a)*(tan_x1))-c)/(b))
... tan_y2 = -((((-a)*(tan_x2))-c)/(b))
... new_line = arcpy.Polyline(arcpy.Array([[arcpy.Point(tan_x1,tan_y1),arcpy.Point(tan_x2,tan_y2)]]),sr) # create line
... new_lines.append(new_line)
... if k > 0:
... new_poly_array.add(new_line.intersect(prev_buff,1).centroid) # find intersections
... new_poly_array.add(new_line.intersect(cur_buff,1).centroid) # find intersections
... else:
... new_poly_array.add(new_line.intersect(cur_buff,1).centroid) # find intersections
... new_poly_array.add(new_line.intersect(prev_buff,1).centroid) # find intersections
... new_rect = arcpy.Polygon(new_poly_array,sr) # make polygon from intersections
... new_scratch_polys.append(new_rect) # add rectangle to scratch geometry
... cur_poly = cur_poly.union(new_rect) # add rectangle to cumulative geometry
... else:
... cur_poly = cur_buff # add buffer to cumulative geometry
... prev_rad = cur_rad #remember values
... prev_pnt = pnt
... prev_buff = cur_buff
... buffers.append(prev_buff)
... new_polys.append(cur_poly) # add cumulative geometry to list
... arcpy.CopyFeatures_management(buffers,r'in_memory\buffers') # write outputs
... arcpy.CopyFeatures_management(new_scratch_polys,r'in_memory\scratch_polys')
... arcpy.CopyFeatures_management(new_lines,r'in_memory\lines')
... arcpy.CopyFeatures_management(new_polys,r'in_memory\polys')
... View more
07-25-2016
12:20 PM
|
3
|
1
|
3786
|
|
POST
|
One sticking point may be that len is a built-in function, returning length of an object, so it may not like that. Also, you probably don't want to run CopyFeatures on each iteration, but build a list of geometries inside the loop and run CopyFeatures afterwards, or use an InsertCursor rather than SearchCursor to write new geometries inside the cursor.
... View more
07-22-2016
10:31 AM
|
0
|
2
|
1977
|
|
POST
|
In your example, the variable 'line' is actually a polyline geometry object (line.segmentAlongLine()). You are trying to apply segmentAlongLine to a cursor object. Try something like: arcpy.CopyFeatures_management(row[1].segmentAlongLine(0, len, False), out_fc)
... View more
07-22-2016
09:50 AM
|
1
|
4
|
1977
|
|
POST
|
I don't think there is a single tool that will do this out of the box, but you can think of it as a two part problem: 1.) Create a point at the nearest location on the line 2.) Split by point #1 is the tricky part, and the way you do it will depend on your licensing and version. With advanced license, you can use Generate Near Table to get XY coordinates. With 10.2+, you can use arcpy Polyline queryPointAndDistance method (all licenses). edit: I didn't realize you could set a search radius with the advanced tool, Split Line by Point. That's a better advanced license solution.
... View more
07-22-2016
09:24 AM
|
1
|
0
|
1492
|
|
POST
|
Maybe I'm thinking about this the wrong way, but I don't see this as a network problem at all. If you attribute your lines with bike speed or time, you can then intersect it with your grid to get the total length of each line type, multiply the length by the speed or time to get the total per line type within the grid cell, then add those all up to get the grid cell total. So, say you've got 2 miles of primary road and 10 miles of secondary road in a grid cell. You decide that you can bike 20mph on primary and 10mph secondary. 20mph = 0.05h/mile, 10mph = 0.1h/mile. 2 * 0.05 = 0.1h on primary, 10 * 0.1 = 1h on secondary. Total time = 1.1h or 66 minutes. edit: OR are you trying to determine how long it would take a cyclist to physically visit each street, possibly including time outside the grid cell?
... View more
07-20-2016
03:07 PM
|
2
|
0
|
1972
|
| 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
|