|
POST
|
I added the toolbox at the other thread: Re: Creating Polylines to track migration
... View more
01-23-2015
01:37 PM
|
0
|
0
|
1032
|
|
POST
|
Find attached the toolbox. In case of any problems, please post them back. The toolbox was created with ArcGIS 10.3.
... View more
01-23-2015
01:36 PM
|
1
|
2
|
2806
|
|
POST
|
If I'm correct you can download the ZIP which does not need an installation... Downloads - pyscripter - An open-source Python Integrated Development Environment (IDE) - Google Project Hosting zip file for registry free installation
... View more
01-23-2015
01:21 PM
|
1
|
9
|
2434
|
|
POST
|
I didn't run the code, but when I do I use PyScripter.
... View more
01-23-2015
01:07 PM
|
0
|
0
|
2434
|
|
POST
|
I think it should be: mxd = arcpy.mapping.MapDocument("CURRENT")
path = r"E:\ned10DEM\Contours"
mxd.replaceWorkspaces(r"E:\FY2011_projects\10mNED\Contours","SHAPEFILE_WORKSPACE", path,"SHAPEFILE_WORKSPACE") each time you specify a path (as string) place the r in front of it.
... View more
01-23-2015
12:39 PM
|
0
|
13
|
2434
|
|
POST
|
Glad it worked. The r is for "Raw String Notation": https://docs.python.org/3.3/library/re.html#raw-string-notation (sorry 3.3 docs)https://docs.python.org/3.3/library/re.html#raw-string-notation If you copy and paste a path in python code it will probably be invalid since you have to use double backward slashed, forwards slashes or the r in front of the string holding the path. Normally the last option is the easiest,
... View more
01-23-2015
11:54 AM
|
0
|
16
|
2434
|
|
POST
|
That shouldn't be a problem if you run the code from the Python Window inside ArcMap. What happens if you place an r before "E:\State_mosaic\Elevations.gdb": mxd.replaceWorkspaces("","NONE",r"E:\State_mosaic\Elevations.gdb","FILEGDB_WORKSPACE",True)
... View more
01-23-2015
11:42 AM
|
0
|
18
|
3633
|
|
POST
|
Let me know if you are interested in some additional explanation on the code... then I'll include it.
... View more
01-23-2015
11:28 AM
|
0
|
0
|
1915
|
|
POST
|
Yep you are right. Change the code on line 53 into: lst_vals = list(valueList[num-1]) The "-1" is missing in the previous code
... View more
01-23-2015
11:27 AM
|
0
|
2
|
1915
|
|
POST
|
Not sure if you are still watching this thread, but I just responded to a similar post: Re: Creating Polylines to track migration The script creates curves like these. Will probably convert into script and include taking the attributes of the table with it. Then you can symbolize the lines using values from the input.
... View more
01-23-2015
10:20 AM
|
0
|
1
|
1032
|
|
POST
|
In case you don't want to have straight lines you could do something like this (black lines are the curves created in the script): ... using a little of Python code (ugly, I know, but will clean it up and convert it into a toolbox later...) import arcpy
import math
def main():
tbl = r"D:\Xander\GeoNet\MigrationRoutes\gdb\test.gdb\test_tbl"
fc_out = r"D:\Xander\GeoNet\MigrationRoutes\gdb\test.gdb\migration06"
sr = arcpy.SpatialReference(28992)
flds = ("X1", "Y1", "X2", "Y2")
curvature = 0.05 # 5%
pnts_on_curve = 100
lst_lines = []
with arcpy.da.SearchCursor(tbl, flds) as curs:
for row in curs:
pnt1 = arcpy.Point(row[0], row[1])
pnt2 = arcpy.Point(row[2], row[3])
line = arcpy.Polyline(arcpy.Array([pnt1, pnt2]), sr)
length = line.length
offset = curvature * length
delta_x = row[2] - row[0]
delta_y = row[3] - row[1]
# extract points on line
arr = arcpy.Array()
for i in range(0, pnts_on_curve + 1):
frac = i / float(pnts_on_curve)
pnt = line.positionAlongLine(frac, use_percentage=True)
line_perp = perpendicular_line(line.firstPoint, line.lastPoint, pnt.firstPoint)
asin = math.sin(frac * math.pi)
dist_off = offset * asin
pnt_new = line_perp.positionAlongLine(dist_off, use_percentage=False)
arr.add(pnt_new.firstPoint)
line_new = arcpy.Polyline(arr, sr)
lst_lines.append(line_new)
arcpy.CopyFeatures_management(lst_lines, fc_out)
class Coord(object):
def __init__(self,x,y):
self.x = x
self.y = y
def __sub__(self,other):
# This allows you to substract vectors
return Coord(self.x-other.x,self.y-other.y)
def __repr__(self):
# Used to get human readable coordinates when printing
return "Coord(%f,%f)"%(self.x,self.y)
def length(self):
# Returns the length of the vector
return math.sqrt(self.x**2 + self.y**2)
def angle(self):
# Returns the vector's angle
return math.atan2(self.y,self.x)
def normalize(coord):
return Coord(
coord.x/coord.length(),
coord.y/coord.length()
)
def perpendicular(coord):
return Coord(
coord.length()*math.cos(coord.angle()+math.pi/2),
coord.length()*math.sin(coord.angle()+math.pi/2)
)
def perpendicular_line(coord_from, coord_to, coord_at):
length = math.hypot(coord_from.X - coord_to.X, coord_from.Y - coord_to.Y)
a = Coord(coord_from.X, coord_from.Y)
b = Coord(coord_to.X, coord_to.Y)
perp = perpendicular(normalize(a-b))
perp_len = Coord(perp.x*length, perp.y*length)
coord_perp = Coord(perp_len.x+coord_at.X, perp_len.y+coord_at.Y)
return arcpy.Polyline(arcpy.Array([coord_at,
arcpy.Point(coord_perp.x, coord_perp.y)]))
if __name__ == '__main__':
main()
... View more
01-23-2015
10:16 AM
|
0
|
3
|
2806
|
|
POST
|
To show you more or less how you can do this: import os
import datetime
currentdate = datetime.date.today()
print currentdate
out_name = "C:\\Users\\xander_mavrides\\Desktop\\DAILY ESO_Moratorium_List.xls"
xls_path, xls_fullname = os.path.split(out_name)
print "xls_path : {0}".format(xls_path)
print "xls_fullname : {0}".format(xls_fullname)
xls_name, xls_ext = os.path.splitext(xls_fullname)
print "xls_name : {0}".format(xls_name)
print "xls_ext : {0}".format(xls_ext)
new_xls_fullname = "{0}_{1}{2}".format(xls_name, currentdate, xls_ext)
print "new_xls_fullname : {0}".format(new_xls_fullname)
new_xls_filepath = os.path.join(xls_path, new_xls_fullname)
print "new_xls_filepath : {0}".format(new_xls_filepath) returns: 2015-01-23 xls_path : C:\Users\xander_mavrides\Desktop xls_fullname : DAILY ESO_Moratorium_List.xls xls_name : DAILY ESO_Moratorium_List xls_ext : .xls new_xls_fullname : DAILY ESO_Moratorium_List_2015-01-23.xls new_xls_filepath : C:\Users\xander_mavrides\Desktop\DAILY ESO_Moratorium_List_2015-01-23.xls
... View more
01-23-2015
09:15 AM
|
1
|
0
|
822
|
|
POST
|
If you have a table with the X,Y (or lat, lon) of the from and to locations on a single record you can use the XY To Line (Data Management) tool. This will create straight lines between the from and to locations. The bad thing about this is that if you have migration between two locations in both directions, it will overlap.
... View more
01-23-2015
05:01 AM
|
0
|
4
|
2806
|
|
POST
|
Where there any changes to the proxy recently? Maybe something in this blog post might help: Troubleshooting issues adding ArcGIS Online basemaps to ArcMap | Support Services Blog
... View more
01-23-2015
04:12 AM
|
0
|
0
|
2566
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
4 weeks ago
|