POST
|
Thanks for pointing out my errors Robert. I went over it several times and thought I had all of my errors fixed. And the tutorial itself was hard to tell in the script examples how each piece was to line up with the other as far as indentation goes. I'm not sure how picky JavaScript is in regards to indentation. My main experience is with Python and even that I'm still rather green at using.
... View more
11-27-2017
06:36 AM
|
0
|
0
|
588
|
POST
|
I'm new to JavaScript and I'm in the process of doing the ArcGIS API for JavaScript tutorial for "Use an ArcGIS.com webmap." I've followed the tutorial step by step and for some reason I cannot get the application to run at the midway point or at the end. The tutorial is somewhat vague for someone new like me. I'm not sure where my error is in the script. I've used both the test web map provided and my own web map, neither working. Any assistance would be greatly appreciated! Below is the website link for the tutorial: Build a web map using ArcGIS.com | Guide | ArcGIS API for JavaScript 3.22 Below is the JavaScript: <!DOCTYPE html>
<html>
<head>
<title>Create a Web Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.22/esri/css/esri.css">
<style>
html,body,#mapDiv,.map.container{
padding:0;
margin:0;
height:100%;
}
#legendDiv{
background-color: #fff;
position: absolute !important;
z-index: 99;
top:10px;
right:20px;
}
</style>
<script>var dojoConfig = { parseOnLoad:true };</script>
<script src="https://js.arcgis.com/3.22compact/"></script>
<script>
var map;
require([
"esri/map",
"esri/arcgis/utils",
"esri/dijit/Legend"
"dojo/domReady!"], function(Map, argisUtils, Legend){
arcgisUtils.createMap("84a3d030b39c4e58aaa68ee9044849f5", "mapDiv").then(function (response) {
map = response.map;
var legend = new Legend({
map: map,
layerInfos:(arcgisUtils.getLegendLayers(response))
}, "legendDiv");
legend.startup();
});
</script>
</head>
<body>
<div id="mapDiv"></div>
<div id="legendDiv"></div>
</body>
</html>
... View more
11-26-2017
02:26 PM
|
0
|
5
|
1045
|
POST
|
I just thought I had to truly only change the arcpy.Select_analysis. That the folder paths didn't necessarily need to be changed, that you were just pointing out how those should be in the future. I didn't think they were the actual cause of my errors. I did go in and change them this time. Still got the same error codes. I relooked over my entire script and found that line 24 was incomplete. if not os.path.exists(outputDir): It should have been: if not os.path.exists(outputDir + '//' + geoDatabaseName + '.gdb'): After that was corrected, everything ran as it should have per the exercise requirements. Thanks again for your input. I'm learning the hard way how one little mistake can cause an entire script to fail.
... View more
11-19-2017
09:45 AM
|
0
|
1
|
962
|
POST
|
I tried what you suggested above and got more error codes this time. See below: Executing: SplitFeaturebyAttribute "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13\test.shp" "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13" test Start Time: Sun Nov 19 11:14:00 2017 Running script SplitFeaturebyAttribute... *Geodatabase exists test in C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13 Traceback (most recent call last): File "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\SplitFeaturesbyAttribute.py", line 51, in <module> splitbyAttribute(inputFc, outputDir, 'CLASS') File "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\SplitFeaturesbyAttribute.py", line 48, in splitbyAttribute arcpy.Select_analysis(fc, newfc, '"{}" = \'{}\''.format(field, value)) File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 84, in Select raise e ExecuteError: ERROR 000210: Cannot create output C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13//test.gdb//Class1 Failed to execute (Select). ERROR 000210: Cannot create output C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13//test.gdb//Class1 Failed to execute (Select). Completed script SplitFeaturebyAttribute... Failed to execute (SplitFeaturebyAttribute). Failed at Sun Nov 19 11:14:00 2017 (Elapsed Time: 0.04 seconds)
... View more
11-19-2017
08:18 AM
|
0
|
0
|
962
|
POST
|
I'm working through an exercise for my Python class and my understanding/experience with Python is very limited. In the end, once the script is built, I should come across one error that was purposely built into the script by the instructor, which I must fix, but when I run my script there seems to be more than one error. And in all honesty, I have looked over the step by step guide and cannot see why I am getting these errors. Any help would be greatly appreciated! Here is the premise of the exercise: Right click on the SplitFeaturebyAttribute.py python script that you created in part 1 and select Edit with Notepad++. The next step is to add the actual logic that will execute the split and export of each unique feature class. To do this the script will have to perform the following tasks: 1. Check to see if the destination geodatabase exits in the output directory. 2. Cursor through the input feature class to find the unique classes. 3. Split and export/create the unique feature classes. To do this we will write a function that takes in the script tool input parameters (e.g. inputFc, outputDir, and geodatabaseName). When working with data and workspace paths a common python module to use is os (click os to view its library page). For the first task listed above we will have to first check to see if the output directory geodatabase exist or not. If it exists, then the next step will be to cursor through the feature class. If the geodatabase does not exist, then the script will create a new geodatabase. This logic may be represented using an if/else conditional logic statement. We will use a os function called os.path.exists to check to see if the geodatabase exists or not. Below is the error statement I keep getting: Executing: SplitFeaturebyAttribute "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13\test.shp" "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13" test Start Time: Sat Nov 18 18:27:55 2017 Running script SplitFeaturebyAttribute... *Geodatabase exists test in C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13 Traceback (most recent call last): File "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\SplitFeaturesbyAttribute.py", line 51, in <module> splitbyAttribute(inputFc, outputDir, 'CLASS') File "C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\SplitFeaturesbyAttribute.py", line 48, in splitbyAttribute arcpy.Select_analysis(fc, newfc, field + '= ' + "'" + value + "'") File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 84, in Select raise e ExecuteError: ERROR 000210: Cannot create output C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13//test.gdb//Class1 Failed to execute (Select). ERROR 000210: Cannot create output C:\CSCC\Courses\GIS 2120\Unit 11\Unit11\Part2\10_13_13//test.gdb//Class1 Failed to execute (Select). Completed script SplitFeaturebyAttribute... Failed to execute (SplitFeaturebyAttribute). Failed at Sat Nov 18 18:27:55 2017 (Elapsed Time: 0.05 seconds) Below is my script: """
---------------------------------------------------------------------------------------------
SplitFeatureAttribute.py
Author: Kevin Surbella
Organization: CSCC
Date: 11/10/2013
Description: This script splits a feature class by
defined field unique classes.
---------------------------------------------------------------------------------------------
"""
import os, arcpy
inputFc = arcpy.GetParameterAsText(0)
outputDir = arcpy.GetParameterAsText(1)
geoDatabaseName = arcpy.GetParameterAsText(2)
try:
#check to see if geodatabase exists. Note geodatabase is a workspace.
if not os.path.exists(outputDir):
arcpy.CreateFileGDB_management(outputDir, geoDatabaseName, 'CURRENT')
else:
arcpy.AddMessage('\n*Geodatabase exists ' + geoDatabaseName + ' in ' + outputDir)
arcpy.env.overwriteOutput = True
def splitbyAttribute(fc, outDir, field):
valueList = []
valueSet = set()
with arcpy.da.SearchCursor(fc, field) as cursor:
for row in cursor:
if row[0]:
if row[0] not in valueSet:
valueList.append(row[0])
valueSet.add(row[0])
for value in valueList:
newfc = outDir + '//' + geoDatabaseName + '.gdb//' + value
arcpy.Select_analysis(fc, newfc, field + '= ' + "'" + value + "'")
arcpy.AddMessage('\nfeature exported = ' + newfc + '\n')
splitbyAttribute(inputFc, outputDir, 'CLASS')
except Exception, e:
import traceback
map(arcpy.AddError, traceback.format_exc().split("\n"))
arcpy.AddError(str(e))
... View more
11-18-2017
03:42 PM
|
0
|
7
|
1867
|
POST
|
Thanks Dan! I appreciate the information you provided. It makes sense to me now.
... View more
10-29-2017
07:43 AM
|
0
|
0
|
940
|
POST
|
Xander, I was wondering if you could explain the assignment of row[0] and row[1]. How do I know that row[0] should go with "DBH" in the table? Is it based on the fact that "DBH" was listed first in your fields assignment within the python code? And is it always the case that the first row will always be assigned [0]?
... View more
10-29-2017
07:00 AM
|
0
|
2
|
940
|
POST
|
Thanks Xander! I appreciate the insight to the other methods I could use to achieve the same end result. I remember learning about dictionaries in class. And now seeing your input I can see how that would have been a much better method if my list of variables needing changed had been longer. It was also nice to see how you could make it case insensitive, thus eliminating any data loss due to incorrect case.
... View more
10-28-2017
03:40 AM
|
1
|
0
|
3711
|
POST
|
Thanks for the newbie wisdom Joe! All the replies on here have been helpful with this problem. It's always good to get a different explanation of why we use the things we do for each python problem I've been challenged with in my class versus the sometimes vague ones I get in class. And making mistakes along the way and learning from them is a lot more helpful for me even if it is stressful!
... View more
10-27-2017
05:24 PM
|
0
|
5
|
3711
|
POST
|
Thanks Dan! By making the suggested change from if field == "Fourth": to if "Fourth" in field: and then the previous change from Randy of adding the prefix return in front of field.replace("Fourth","4th"), the field calculator tool ran as expected.
... View more
10-27-2017
02:57 PM
|
0
|
1
|
3711
|
POST
|
Thanks for the input! I got same answer on another forum where I posted the same question. I made the suggested changes. When I ran the Field Calculator tool this time, I got no error codes, but none of the values changed in the "FULLNAME" field. "Fourth" stayed as "Fourth" instead of changing to "4th".
... View more
10-27-2017
02:47 PM
|
0
|
0
|
3711
|
POST
|
I'm new to python and trying to write a python script using the field calculator in ArcMap for a specific field in an attribute table that will replace some of the values in the field but leave the other values as they are within the table. For example: ""fourth" must be changed to "4th" whereas "Neilston" should remain as it is in the field. The field in the table looks like this: The python script used in the codeblock looks like this: def streetNUM(field): if field == "Fourth": field.replace ("Fourth","4th") elif field == "Fifth": field.replace ("Fifth","5th") else: return field And then in the box below the codeblock I have: streetNUM(!FULLNAME!) Nothing seems to change and I get an error code saying "Field is not nullable [FULLNAME]". Any suggestions as to where I may be going wrong with my code?
... View more
10-27-2017
02:00 PM
|
1
|
12
|
7827
|
POST
|
Thanks Curtis! Through another forum a user pointed out that the issue with my model was that I was trying to use the same name for a feature class in one dataset that already existed in another dataset within the same geodatabase. Once I corrected that, then the model ran as expected.
... View more
10-27-2017
01:46 PM
|
1
|
1
|
782
|
Title | Kudos | Posted |
---|---|---|
1 | 10-27-2017 02:00 PM | |
1 | 10-27-2017 01:46 PM | |
1 | 10-28-2017 03:40 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|