|
POST
|
"Network Analyst" makes sense in the URL path. Perhaps our comments will also make sense to the OP.
... View more
05-22-2017
02:20 PM
|
0
|
0
|
2815
|
|
POST
|
I was considering that possibility. I thought one might be Japan and the other Poland. If so, this would be between Europe and Japan (and thus between 2 regions). I think the NAServer is just for the North America region. I believe this service is looking for a driving route between locations. If a straight line distance is desired, using a great circle or Dan Patterson's Vincenty calculator would be an easier solution.
... View more
05-22-2017
01:16 PM
|
0
|
7
|
2815
|
|
POST
|
I believe your longitude and latitude pairs are in the ocean and not in North America. Also longitude should be negative for NA.
... View more
05-22-2017
12:15 PM
|
0
|
9
|
2815
|
|
POST
|
Are you working with a shape file in ArcMap's python window? If so, I think you need to be in an edit session for the shape file to be updated. Or are you working with a feature in a file geodatabase?
... View more
05-11-2017
10:10 PM
|
0
|
2
|
2990
|
|
POST
|
This uses Arkadiusz Matoszka's suggestion (from the link I posted above). It uses a dictionary in a manner similar to what you were trying. But it can run inside the UpdateCursor block, so you don't need the SearchCursor code. (Also, "Count" might not be a good field name as it may be an SQL reserved word.) import arcpy
# find duplicate records and count them in dictionary
inShapefile = 'VacantLots'
checkField = "P_ID"
updateField = "fieldCount" # renamed field
d = {} # dictionary for counting
with arcpy.da.UpdateCursor(inShapefile, [checkField, updateField]) as rows:
for row in rows:
if row[0] not in d.keys():
d[row[0]] = 0 # insert key into dictionary and set value to 0
row[1] = 0 # value into updateField
else:
d[row[0]] += 1 #increment value in dictionary
row[1] = str(d[row[0]]) # save value in updateField (str for text field)
rows.updateRow(row)
... View more
05-10-2017
03:21 PM
|
0
|
4
|
2990
|
|
POST
|
An old thread that might help: Identify duplicate records & increment
... View more
05-09-2017
04:10 PM
|
1
|
0
|
2990
|
|
POST
|
Looks like in line 19 of code, the date isn't getting inserted in the string. Also "=" is being used instead of ">" or "<".
... View more
05-04-2017
11:34 AM
|
0
|
0
|
2192
|
|
POST
|
My thoughts: import datetime as DT
today = DT.date.today()
month_ago = today - DT.timedelta(days=30)
expDate = "CreationDate < DATE '{}'".format(month_ago)
print expDate
... View more
05-04-2017
11:19 AM
|
0
|
2
|
2192
|
|
POST
|
Try something like: >>> hwy = "699 HWY #4"
>>> hwy
'699 HWY #4'
>>> print hwy.lstrip('0123456789.- ')
HWY #4
... View more
05-04-2017
09:42 AM
|
2
|
1
|
1247
|
|
POST
|
Here's a version of the previous script that puts the x and y coordinates into a comma delimited format. # print a header row - comma delimited
print "{}, {}, {}, {}, {}".format(
'"OBJECTID"',
'"X_WebM"',
'"Y_WebM"',
'"X_Lon"',
'"Y_Lat"'
)
# we will assume the feature is in web mercator
for row in arcpy.da.SearchCursor("MyPointLayer",["OID@","SHAPE@XY"]):
# SHAPE@XY contains both x and y coordinates
px, py = row[1]
# convert px and py to longitude and latitude
# WGS 1984 : (4326) Lat/Lon
# WGS 1984 Web Mercator (auxiliary sphere) : (102100) or (3857)
ptGeometry = arcpy.PointGeometry(arcpy.Point(px,py),
arcpy.SpatialReference(3857)).projectAs(arcpy.SpatialReference(4326))
print "{}, {}, {}, {}, {}".format(
row[0], # OBJECTID
px, # X_WebM
py, # Y_WebM
ptGeometry.firstPoint.X, # X_Lon
ptGeometry.firstPoint.Y # Y_Lat
)
This should make it easier to see how to separate the geometry into columns. You can add other attribute fields to the list in the Search Cursor: for row in arcpy.da.SearchCursor("MyPointLayer",["OID@","SHAPE@XY","FieldName"]):
....
row[2] # FieldName
... View more
05-03-2017
10:08 AM
|
2
|
0
|
2853
|
|
POST
|
This provides some interesting results. By specifying a spatial reference in the search cursor, you can get latitude and longitude very easily. And it is easy to have tab delimited output. # WGS 1984 : (4326) Lat/Lon
print "{}\t{}\t{}".format(
"OBJECTID",
"POINT_X",
"POINT_Y"
)
for row in arcpy.da.SearchCursor("MyPointLayer",["OID@","SHAPE@X","SHAPE@Y"],spatial_reference=arcpy.SpatialReference(4326)):
print "{}\t{}\t{}".format(
row[0], # OBJECTID
row[1], # POINT_X (LON)
row[2] # POINT_Y (LAT)
)
... View more
05-02-2017
05:38 PM
|
1
|
0
|
501
|
|
POST
|
Using a search cursor, you can loop through the points in a feature class, read the geometry and convert to longitude/latitude. Something like this: for row in arcpy.da.SearchCursor("MyPointLayer",["OID@","SHAPE@XY"]):
print("Feature {}:".format(row[0])),
px, py = row[1]
print("{}, {}".format(px, py)),
# WGS 1984 : (4326) Lat/Lon
# WGS 1984 Web Mercator (auxiliary sphere) : (102100) or (3857)
ptGeometry = arcpy.PointGeometry(arcpy.Point(px,py),arcpy.SpatialReference(3857)).projectAs(arcpy.SpatialReference(4326))
print ptGeometry.firstPoint.X, ptGeometry.firstPoint.Y This code may be helpful in getting the spatial reference information for the point feature: SR = arcpy.Describe("MyPointLayer").spatialReference
print SR.name
print SR.factoryCode
... View more
05-02-2017
03:30 PM
|
2
|
2
|
2853
|
|
POST
|
Hello John, When I export a point feature to a CSV or Excel table, I like to have the X and Y coordinates in longitude and latitude. To do this, I use the Add Geometry Attributes tool before exporting my table. This tool adds two columns, Point_X and Point_Y, to your feature. By specifying a spatial reference, you can have the XY in longitude/latitude. This tool does modify the input table by adding these columns. You could make a copy of your feature, perhaps "in-memory", and modify it if you did not want the columns in your original feature. I would use the following code in your script before your lines to export to csv to create and populate the feature with Point_X and Point_Y fields: spatial_reference = arcpy.SpatialReference("WGS 1984")
arcpy.AddGeometryAttributes_management(fc,"POINT_X_Y_Z_M","#","#",spatial_reference) Like Neil Ayres, I am confused by your files dictionary. I am not sure why you are adding a second SHAPE@X/Y (X is Long and Y is Lat), so I would suggest dropping this. Instead of using Add Geometry Attributes, you might try something like this to get longitude and latitude: for row in arcpy.da.SearchCursor("MyPointLayer",["OID@","SHAPE@XY"]):
print("Feature {}:".format(row[0])),
px, py = row[1]
print("{}, {}".format(px, py))
# WGS 1984 : (4326) Lat/Lon
# WGS 1984 Web Mercator (auxiliary sphere) : (102100) or (3857)
ptGeometry = arcpy.PointGeometry(arcpy.Point(px,py),arcpy.SpatialReference(3857)).projectAs(arcpy.SpatialReference(4326))
print ptGeometry.firstPoint.X, ptGeometry.firstPoint.Y Hope this helps.
... View more
05-02-2017
01:59 PM
|
0
|
0
|
3965
|
|
POST
|
Try: mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
# to read minScale
print lyr.minScale
# to set minScale
lyr.minScale = 500.0
... View more
04-28-2017
02:22 PM
|
2
|
1
|
2906
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
07:13 PM
|