|
POST
|
Dan posted the solution, ill rewrite it more explicitly for your question. You can pass as many values/fields to a function as you like so that you can then return their values. def compare(class1, class2, class3):
if class1 in (612, 611):
return class2
elif class1 == 617:
return class3
else:
return class1
# Expression below
compare(!some_field!, !another_field!, !another_field2!)
... View more
12-05-2018
04:49 AM
|
1
|
0
|
1927
|
|
POST
|
The issue is if I write in the python window: data = [] for row in some_fc: data.append(row stuff) I now have this in memory,. Clearing the screen is good, but I can still do : print data to get back my stuff, so memory is used. How to release this?
... View more
10-22-2018
10:02 AM
|
0
|
2
|
5301
|
|
POST
|
It depends where you chose when you installed ArcGIS. For me its this file here: C:\Program Files\ArcGIS\Pro\bin\Python\python.exe
... View more
10-01-2018
08:19 AM
|
0
|
1
|
5432
|
|
POST
|
When in the "Data Driven Page Setup" window where you selected the layer to be used as the data driven index, you are able to select a 'Name Field'. Subsequently, when exporting map, choose the 'Pages' tab, and select the option to export all maps, using a 'name'. When you enter a name into the GUI for your maps, it will then add the name attribute to the end. For example you enter "Maps_" and it will export "Maps_Map1Name.pdf", Maps_Map2Name.pdf" etc.
... View more
09-06-2018
05:41 AM
|
1
|
0
|
868
|
|
POST
|
Hi Mark, For us, our license server is in the USA, whereas we work in the UK. We notice that the script above can on a good day, run in approx 5 seconds. But when our LAN is slow, it can take 30-45 seconds, which when your changing 1 charecter in a script can be frustrating. Checking out (borrowing) the license using Adminstrator may help, havent actually tried it! (Dont do much python at the moment sadly)
... View more
07-20-2018
08:49 AM
|
0
|
0
|
1338
|
|
POST
|
Speaking from a very high level. (It would take me quite some time to understand all the code) It looks like you calculate the offsets using either the X or Y plane only. I think this could account for the widths looking to be not of relative size as the smaller 17 is almost exactly on the XY axis whose width was then extrapolated using either X or Y only, whereas the larger 11 is almost perfectly on the X axis. (So has ended up with a "correct" relative width) If the statement above is wrong, please stop reading here! You could look to create the offset on all axis using code such as (Again very high level, semi pseudo code to give ideas only likely with syntax issues as typed in notepad: beforePoint = aPointCursorRow
currentPoint = aPointCursorRowWereTurningToAPolygon
dX = current.shape.Centroid.X - beforePoint.shape.Centroid.X
dY = current.shape.Centroid.Y - beforePoint.shape.Centroid.Y
angle = atan2(dX, dY) * 180 / pi
distance = width_factor(current.attributeValue)
newpoint1 = currentPoint.shape.pointFromAngleAndDistance(angle + 90, distance)
newpoint2 = currentPont.shape.pointFromAngleAndDistance(angle + 90, distance)
coordinates = [beforePoint, newpoint1, currentPoint, newpoint2] **Final Note - You probably would want to use 3 'rows' instead of 2 to make each point. -possibly substituting currentPoint for nextPoint at the final co-ordinates step. - calculating the "Angle" using all 3 points, instead of 2 in case the direction chages a lot. (Except for the start and end of the data where you obviously only have 2 points!)
... View more
07-20-2018
08:39 AM
|
2
|
1
|
1989
|
|
POST
|
Following that, I noticed you are trying to compare a feature datasource to oldP... which is actually a list, so cant really be compared. (You need to compare it to the paths insdie this list, as it will never equal the list) I wrote a version that should probably work: import csv
import arcpy
# set up list for data
dataMappingList = []
# read data from file and store in lists
with open(r"C:\hardcode_to_Path\dsListTEST.csv", "rb") as dsList:
r= csv.reader(dsList,delimiter=",")
for i,row in enumerate(r):
if i>0: #skip the header
#To make mapping the old paths to new paths easier, we store each dataset as a list
data_list_item = [str(row[0]), str(row[1]), str(row[2])]
#Then we put them in our master list, which will hold a list, of lists!
dataMappingList.append(data_list_item)
# replace the existing datasource with the new path, feature class name and layer name.
mxd = arcpy.mapping.MapDocument(r"hardcode_to_testMap.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
for data_list_item in dataMappingList:
if lyr.dataSource == data_list_item[0]:
lyr.replaceDataSource(r"Hardcode_to_new_location","None",data_list_item[1], True)
lyr.name = data_list_item[2]
print lyr.dataSource
mxd.saveACopy(r"hardcode_to_Copy_testMap.mxd")
del mxd
dsList.close()
... View more
03-23-2018
07:37 AM
|
1
|
1
|
1256
|
|
POST
|
Theres an indentation issue causing the script to overwrite the mxd for each line in the CSV. Not sure if copy paste issue or actual problem! # set up blank lists for data
oldP,newF,newL = [],[],[]
# read data from file and store in lists
with open(r"C:\hardcode_to_Path\dsListTEST.csv", "rb") as dsList:
r= csv.reader(dsList,delimiter=",")
for i,row in enumerate(r):
if i>0: #skip the header
oldP.append(str(row[0]))
newF.append(str(row[1]))
newL.append(str(row[2]))
# replace the existing datasource with the new path, feature class name and layer name.
mxd = arcpy.mapping.MapDocument(r"hardcode_to_testMap.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if lyr.dataSource == oldP:
lyr.replaceDataSource(r"Hardcode_to_new_location","None",newF, True)
lyr.name = newL
print lyr.dataSource
mxd.saveACopy(r"hardcode_to_Copy_testMap.mxd")
del mxd
dsList.close()
... View more
03-23-2018
03:43 AM
|
0
|
2
|
1256
|
|
POST
|
Im not sure I understand the question! If you are copying FROM the database into a FC, any copy rows / featureclass to featureclass should work, as objectID is managed by the shapefile / FileGDB without problems. I understand why you may be having difficulty storing data inside the database as I have had similar issues, but your workflow is the opposite way round no? Anyways, I only ever manged to insert data into SQL via SQL queries 1 row at a time in a loop, using the functions described here to get the next objectID: Next_RowID—Help | ArcGIS Desktop
... View more
03-15-2018
05:02 AM
|
0
|
0
|
1559
|
|
POST
|
The API terms state: 50 requests per second, calculated as the sum of client-side and server-side queries. Your code does: time.sleep(.1) So I am not sure why you hit these issues. However, there help file has an example script that demonstrates how to work around this issue: url = "MAPS_API_WEBSERVICE_URL"
attempts = 0
success = False
while success != True and attempts < 3:
raw_result = urllib.urlopen(url).read()
attempts += 1
# The GetStatus function parses the answer and returns the status code
# This function is out of the scope of this example (you can use a SDK).
status = GetStatus(raw_result)
if status == "OVER_QUERY_LIMIT":
time.sleep(2)
# retry
continue
success = True
if attempts == 3:
# send an alert as this means that the daily limit has been reached
print "Daily limit has been reached"
... View more
03-08-2018
05:20 AM
|
2
|
1
|
3548
|
|
POST
|
How do you connect to it inside ArcMAP...using normal techniques? (Does it work as a standard 'add database connection', or do you require to connect via OLE DB methods?) (I work in a Microsoft SQL Server shop)
... View more
02-13-2018
06:13 AM
|
0
|
0
|
801
|
|
POST
|
Im interested in what you are trying to achieve with the code here: new_layer = arcpy.mapping.Layer(new_layer_name) As you are simply passing it a string, no paths to any data or anything. dataset_to_process = r'FULL_PATH_TO_A_FEATURE_CLASS_IN_A_GEODATABASE'
#e.g. C:\temp\a.gdb\layername
new_layer_name = os.path.basename(dataset_to_process)
#e.g. layername The layer that did get added to your map, came from MakeFeatureLayer_management due to the default arcmap setting. The second bunch of code (arcpy.Mapping.Addlayer etc) should (and does on my pc) have crashed as the layer we make in the above fashion cannot be correct. However I feel it may somehow be making a ghost layer, that has no selections applied for obvious reasons. (e.g. a bug in ESRI, that wont manifest if you use the software as intended)
... View more
02-09-2018
05:34 AM
|
0
|
1
|
891
|
|
POST
|
As Joshua mentions its likely a config issue within pyscripter. Your PC can have as many versions of Python installed as you would like. ArcGIS installs a version, so does ArcGIS pro, so does other software, you may even have just installed one yourself. Only the version of Python that ArcGIS installed itself can use ArcPy. Your pyscripter is likely set to use one of the other versions of python that exist on your computer. This setting is called the "Interpreter", look to change that. I can see in your "Environment Settings" attachment, that the python version 36 does not appear to be one of the ArcGIS python installs.
... View more
01-09-2018
05:04 AM
|
1
|
0
|
8780
|
|
POST
|
Concerns you will need to ensure that each polygon initially has extraneous vertices removed (Generalize, removing points on the perimeter that aren't part of a direction change. To add to this, a shape you see as a 'rectangle', may actually be composed of smaller edges that look like 4 edges when you zoom out far enough inside the GIS. (e.g. the computer sees it as a 18 sided polygon, not a rectangle!) The generalise tool can help simplify the shape, but you need to enter tolerances that make sense with your particular data. Simple example: Actual Coords (5 sided shape to the computer): 1,1 1,2 2,2 2,1 2.02, 1.02 Human interpreted coords (Shape looks like a rectangle to me as the final vertex added nothing): 1,1 1,2 2,2 2,1 In this example, if I generalise the input data with a 0.05m tolerance, it would clean out the node thats not required as the 0.02 metre deviation has less effect on the shape of the polygon than the 0.05 tolerance.. and is therefore not required.
... View more
10-12-2017
06:43 AM
|
0
|
2
|
3660
|
|
POST
|
If you manually calculate the field inside arcmap, you can then copy as a python snippet the required code using the ArcGIS Results window. Geoprocessing --> results I guess you may need code like unless your data is joined: GDBEntrada = "C:\data\mygdb"
arcpy.SelectData_management(GDBEntrada, "ASCFxCC")
expresion = 'funcion( !CODVIA!, !NUMPOL!, !DUPLICADO!)'
... View more
10-02-2017
04:39 AM
|
1
|
0
|
459
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-29-2019 07:45 AM | |
| 1 | 05-13-2013 07:11 AM | |
| 1 | 05-24-2011 07:53 AM | |
| 1 | 05-22-2017 05:01 AM | |
| 2 | 07-29-2019 05:34 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-22-2024
10:40 AM
|