POST
|
Newbie here. I'm self-teaching about cursors and am practicing on this dataset. "testclass" is a feature class with an ID field (6 digit integer) and a name field. I want to go through and assign a unique name based on the ID. The following code works and illustrates more or less what I am trying to do (although I am sure it gives many of you heartburn with how clunky it is-- sorry ). point = "testclass"
update = arcpy.da.UpdateCursor(point,["ID", "name"])
for row in update:
ID = row[0]
if (ID == '174769'):
name = "R4S8f"
row[1] = name
elif (ID == '174771'):
name = "C3F8m"
row[1] = name
elif (ID == '174773'):
name = "F4S8m"
row[1] = name
elif (ID == '174774'):
name = "C1S8f"
row[1] = name
elif (ID == '174776'):
name = "F3S8f"
row[1] = name
elif (ID == '174778'):
name = "R1S8f"
row[1] = name
elif (ID == '174781'):
name = "R6F8f"
row[1] = name
update.updateRow(row) I would like to take this same concept and use an update cursor with a dictionary. I've found several posts online so I think I'm close but I can't quite get the syntax. This is what I have. assignName = {174769 : 'R4S8f', 174771 : 'C3F8m', 174773 : 'F4S8m', 174774 : 'C1S8f',
174776 : 'F3S8f', 174778 : 'R1S8f', 174781 : 'R6F8f'}
cursor = arcpy.da.UpdateCursor('testclass',["ID", "name"])
for row in cursor:
if row.ID in assignName:
updateRow.name = assignName[updateRow.ID]
update.updateRow(row) It's telling me in line 7 "'list' object has no attribute 'ID'" when I run this in ArcGIS Pro. Thanks in advance
... View more
03-07-2019
12:26 PM
|
0
|
7
|
3318
|
POST
|
Getting rid of env.workspace = outWorkspace and then doing FinalRaster.save(outRaster) ended up fixing all of my problems. I guess it was setting the workspace that was causing me issues. Thanks!
... View more
02-22-2019
10:55 AM
|
0
|
1
|
2719
|
POST
|
Thank you both for your reply. After another 45 min- 1 hour of banging my head this is where I'm at: Dan: I've changed my workspace (from the user input end of the script tool) to a folder rather than a gdb. I changed the outRaster to outRaster.tif (again in the user end). I guess I'm unsure how to call my FinalResult and save it in the concatentated file path. FinalResult.save(concatenatedVariable) ? When I try this, I get a 000875 error saying the workspace is an invalid output workspace. Curtis: I've tried the line you added, but I get a 010240 error that it could not save the raster dataset with output format FGDBR. When I run the script in the python window it adds my final raster to my map and it has a temporary location. If I just do FinalRaster.save() in the python window it saves in my workspace without any issues. Thanks again to both of you for your input and patience with my very basic knowledge
... View more
02-22-2019
08:45 AM
|
0
|
0
|
2719
|
POST
|
I'm learning python and have been banging my head on this for hours now and can't figure it out. It's probably something really basic but here it goes... I have a base elevation raster that I'm running some math on to get a basic ruggedness layer. The script works when I run it in the python window, but I'm trying to use it to create a script tool. Here is what I have simplified: outWorkspace = arcpy.GetParameterAsText(0) baseRaster = arcpy.GetParameterAsText(1) scale = arcpy.GetParameterAsText(2) outRaster = arcpy.GetParameterAsText(3) env.workspace = outWorkspace ###lots of math on the baseRaster FinalResult = #more math finalResult.save() When I run it like this, the tool runs but it doesn't appear to save my file in the workspace specified (or anywhere for that matter, I can't find the results of the tool). So I guess that's issue #1. Second question is how do I script this so that the name of FinalResult is whatever the user puts in for outRaster, instead of FinalResult? In case it is needed, my parameters that I have set up in my script tool are as follows: 0 = Workspace (data type), input 1 = Raster Dataset, Input 2 = Long, Input 3 = Raster Dataset, Output
... View more
02-21-2019
01:52 PM
|
1
|
6
|
3084
|
POST
|
I have a point file with 237k points, and I want to convert a text field containing scientific notation values (i.e 9.99E-3) to a double value field. I'm having issues finding a tool or code to do this. Anyone know of an easy way?
... View more
02-07-2019
10:23 AM
|
0
|
1
|
1079
|
POST
|
That did exactly what I wanted, thanks! Somehow I never came across that as I was looking. Thanks again
... View more
08-28-2018
08:01 AM
|
0
|
0
|
1219
|
POST
|
I have a point file of approx. 500 points that represent movement from a GPS collar on an animal. My table has Lat, Long, and a date stamp. I'm looking for a tool that will draw a line sequentially through the points, roughly following the path of the animal. All of the point to polyline tools I've been looking into don't seem to be what I'm looking for. I feel like it should be a basic solution, but my research isn't turning anything up. Can anyone point me in the right direction?
... View more
08-27-2018
02:47 PM
|
0
|
2
|
1495
|
POST
|
It's actually GeoTrak. The data is a little sensitive but if looking at the shapefile would help I could put up an edited version.
... View more
05-11-2018
09:03 AM
|
0
|
1
|
1621
|
POST
|
Adrian It is a GPS tracker on wildlife that sends me points through the company's software. I don't think it's using CAD. Looking at the files contained in the shapefile I don't see anything strange.
... View more
05-10-2018
12:25 PM
|
0
|
3
|
1621
|
POST
|
I've tried both the shapefile and converting it to a file geodatabase, but it's doing the same thing. I forgot to add, there are some new fields in the target database that aren't in the shapefile so I select the use field map option and just delete the unused fields. But I also did that before I started having issues too.
... View more
05-10-2018
12:05 PM
|
0
|
5
|
1621
|
POST
|
I have a point shapefile that I am trying to add to a file geodatabase with 1118 point features. Every couple days I've gotten an updated shapefile, so my process has been append it to my file geodatabase and then delete duplicates, which has worked great until I got to about 1000 points, then I worked around it by merging instead of appending and just making a new file, but I would rather not have to continue doing it that way. I'm getting error 000594 and 595, it says the tool was run with warnings and I still have the same 1118 points, with no new points from the shapefile that I'm trying to append. The suddenness of the issue popping up lead me to believe it was a memory issue, but unless I'm mistaken, my 1000 points are well within the size limit of a file geodatabase. File geodatabase size and name limits—Help | ArcGIS Desktop Am I missing something?
... View more
05-10-2018
09:11 AM
|
0
|
7
|
2242
|
POST
|
As a clarification of what I have/what I want to do, my polygon layer is units within a state (approximately 25) and my table has a field referencing one of those units (i.e "this feature corresponds with unit #3). So ideally I can do some kind of an analysis to count the number of records that correspond with each unit, and then display that as a count field or something so I can symbolize the polygon file based on the count.
... View more
04-19-2018
02:49 PM
|
0
|
1
|
2704
|
POST
|
I have a polygon layer and a table that shows records relating to the different polygons. I have both hosted on ArcGIS online and want to show a chloropleth map (online) showing the number of points that intersect with the polygons. I also want the data to be easy to edit as I will be continually adding to the table, so the fewer steps I have to redo over and over again to update the chloropleth map would be ideal. I've searched forums and tried different tools on ArcPro but nothing is quite working, most of them require an output and I'm not having much luck getting what I want. I've also tried joins and creating a "count" field and different forms of "intersect" type tools, but I can't find the right one.
... View more
04-18-2018
04:08 PM
|
0
|
3
|
5291
|
POST
|
I am in the process of planning a computer build for an upcoming MS project involving some image processing and basic modeling, as well as just having a decent personal computer. Because of price, I'm looking at running my OS and ArcPro/ArcGIS 10.5 off of a SSD of about 250 GB and getting a separate HHD for some personal files and GIS data. Does anyone have any experience combining the two and does it improve the performance enough to justify getting a SSD? Or should I fork up a bit more money and just get a bigger SSD? Thanks!
... View more
02-10-2018
05:57 PM
|
0
|
2
|
1402
|
POST
|
Thanks all for your answers. I converted everything from GRID to TIFF (I'm running 10.3 so it looks like that shouldn't have been it, but I tried it anyway) and I tried saving it into a geodatabase and it worked.
... View more
01-04-2016
04:21 PM
|
0
|
0
|
964
|
Title | Kudos | Posted |
---|---|---|
1 | 11-26-2019 08:43 AM | |
1 | 02-21-2019 01:52 PM | |
1 | 03-07-2019 01:21 PM | |
1 | 01-24-2020 11:36 AM |
Online Status |
Offline
|
Date Last Visited |
01-27-2021
02:11 PM
|