POST
|
When we click the down arrow on a Feature Services within My Content and select "Add to New Map", the layers are in the correct order within the TOC, but they display in reverse order. We can rearrange the TOC layers as usual, and when the layers are reversed in the TOC, they appear correctly on the map. Now it gets weird. If I add the same Feature service a second time to the same map, then the TOC layer order for the newly added layers is still correct, but these layers display in the correct order. The original layers, however, still display in reverse order to the TOC. This behavior began late February or early March. I have not reversed the layer order in the python script because I figured ESRI would notice this right away and fix it, but the behavior is ongoing. Sooo ... is it just us? Paul
... View more
04-29-2014
03:06 PM
|
0
|
0
|
670
|
POST
|
Hi folks. I am using desktop 10.0. I'm trying to improve some performance issues and Extract By Mask is a major choke point. Running the following code:
arcpy.env.scratchWorkspace = "in_memory"
RasterSelection = arcpy.sa.ExtractByMask(infile, inmask) produces the error:
ExecuteError: ERROR 010302: Unable to create the output raster: in_memory\Extract_Dec_1
ERROR 010067: Error in executing grid expression.
Failed to execute (ExtractByMask). If the workspace is left empty (uses defaults) or is set to the gdb that the original raster is in, then it completes successfully. Is there something in my setup that is making it do this? I thought ExtractByMask was supposed to generate an in_memory raster regardless. Why would it write to the scratch workspace at all? I'm not a raster expert by any means. I do try to use objects rather than on-disk references as much as possible. I also just leave the raster format to its default and place them in GDBs, which organizes the file system in a way that works for our group. Thanks in advance. Paul
... View more
04-10-2014
01:12 PM
|
0
|
0
|
517
|
POST
|
We have been using a python script using desktop ArcGIS 10.1 to generate ArcGIS Online maps all winter. Here is the web app showing the maps we have been generating: sniffer maps. Last week one of our techs reported the script was succeeding (no errors thrown) but nothing was showing up in his ArcGIS Online contents. I tried when I got back today and got the following error: ERROR: code:500, Invalid name 'Sniffer Run 2014-03-03, Fairbanks, AK' found in input publish parameters, Cannot connect to this server.
Failed to execute (UploadServiceDefinition). The name, 'Sniffer Run 2014-03-03, Fairbanks, AK' is the service_name passed to arcpy.mapping.CreateMapSDDraft, and is computer generated. I had to eliminate spaces, commas and dashes to make it work. There appears to have been a change in the ESRI side which makes our service_name convention no longer valid during the UploadServiceDefinition stage. Is this a feature or a bug? (Maybe a programmer specified the wrong string encoding.) This makes the map names much less readable for our Online map users, so if we can go back to the way it was we would appreciate it muchly. Thanks! Paul Here is a snippet showing the service definition portion of the code: service = "Sniffer Run " + numdate + ", " + city
serverType = 'MY_HOSTED_SERVICES'
onlineDirectory = "Sniffer_Maps" # this doesn't work
tellMe("Running CreateMapSDDraft ...")
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, serverType, summary=sddraftSummary, tags=sddraftTags)
con = 'My Hosted Services'
sd = os.path.join(srvdefworkspace,service + '.sd')
# Read the sddraft xml.
doc = DOM.parse(sddraft)
# Change service from map service to feature service
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
# Get the TypeName we want to disable.
if typeName.firstChild.data == "MapServer":
typeName.firstChild.data = "FeatureServer"
#caching
configProps = doc.getElementsByTagName('ConfigurationProperties')[0]
propArray = configProps.firstChild
propSets = propArray.childNodes
for propSet in propSets:
keyValues = propSet.childNodes
for keyValue in keyValues:
if keyValue.tagName == 'Key':
if keyValue.firstChild.data == "isCached":
keyValue.nextSibling.firstChild.data = "false"
#add disclaimer text
disclaimer = 'a text string'
disclaimNode = doc.createTextNode(disclaimer)
acc = doc.getElementsByTagName("AccessInformation")[0]
acc.appendChild(disclaimNode)
# add org credits
credits = "FNSB Air Quality"
cre = doc.getElementsByTagName("Credits")[0]
if cre.childNodes == []:
credNode = doc.createTextNode(credits)
cre.appendChild(credNode)
tellMe("Writing XML ...")
outXml = os.path.join(srvdefworkspace,'HostedMSNew.sddraft')
f = open(outXml, 'w')
doc.writexml( f )
f.close()
tellMe("Running AnalyzeForSD ...")
analysis = arcpy.mapping.AnalyzeForSD(outXml)
if len(analysis['errors'])>0:
tellMe( str(analysis))
sys.exit(analysis['errors'])
#arcpy.SignOutFromPortal_server()
## tellMe("Signing In ...")
## username = "*****"
## password = "*****"
## arcpy.SignInToPortal_server(username,password,"http://www.arcgis.com/")
tellMe("Running StageService_server ...")
arcpy.StageService_server(outXml, sd)
tellMe("Running UploadServiceDefinition_server ...")
sharegroup = "Sniffer Map Feature Layer Services"
override = "OVERRIDE_DEFINITION"
arcpy.UploadServiceDefinition_server(sd, con, in_override=override, in_public = "PUBLIC", in_groups=sharegroup)
... View more
03-10-2014
10:44 AM
|
0
|
0
|
2480
|
POST
|
Here is the web app in question. The map that worked is 2013-10-24, presently the center top map, but that will change soon. The other maps still show every layer despite the layers being marked as hide in legend by the user. FNSB AQ map web app
... View more
11-05-2013
09:28 AM
|
0
|
0
|
382
|
POST
|
I am using the configurable gallery web app template. Each map has 4 layers, but I only want 1 layer to show up in the Legend. The first time I tried hiding the layers, saving the layers, and saving the map, it worked. Only the desired layer shows up in the web app legend for that map. Every map we've generated since then all the layers continue to show up in the web app legend. I keep thinking maybe if I can find the specific order of mouse clicks I used for the first map I can get it to work for the rest, but so far no dice. I have found the order of mouse clicks sometimes does make a difference in how the maps appear in the gallery web app. Has anyone else seen this and figured out how to consistently hide those pesky extra layers in the web app legend? Thanks Paul
... View more
10-30-2013
04:41 PM
|
0
|
3
|
921
|
POST
|
Thanks Andrew! It'll be a little while before I have the time to devote to it again, but from what I've read so far it looks like I can get there from here. I'll (try real hard to remember to) mark this as answered once I do. Thanks again! Paul
... View more
10-29-2013
11:33 AM
|
0
|
0
|
419
|
POST
|
Thanks Andrew. It looks promising. I haven't looked at JSON at all (nor Javascript, nor JAVA, nor REST) so I'll need to get an education. I have been able to look at the JSON for a working map and see how it should look. Do you know where I can find a reference for uploading the JSON to the map? I found this document for iphones but I haven't been able to find the equivalent to the "Supported Operations: Add Item" button mentioned there. We are using ArcGIS.com rather than our own server, which is the focus of the iphone document. Thanks again. Paul
... View more
10-14-2013
03:01 PM
|
0
|
0
|
419
|
POST
|
Well, it looks like the pop-ups are a feature of the feature service, not the browser, since configuring them in one browser applies to all. It should be possible to configure the feature service pop-ups by editing the draft service definition. Perhaps ESRI can work on enabling such a feature. I have been unable to find any information otherwise, so it appears that complete web maps can't be generated via PYTHON. Perhaps ESRI can consider adding the ability to apply the metadata from a layer to the map within which it resides. Perhaps a drop down arrow next to the layer in the map's "View item details" screen, or perhaps an "Import from layer" button in the map's Edit item details screen. That way the title, summary, description, all the keys, access and use constraints, and credits can be automatically generated once for the layer, and the user would not have to copy-paste, with the errors inherent with that process, all those into the map.
... View more
10-10-2013
04:52 PM
|
0
|
0
|
419
|
POST
|
We have 3 employees with varying levels of computer savvy who need to generate several unique maps each day to be shared via one of the web app templates. I'm trying to automate as much of that process as possible. I can publish a feature service and share it with its appropriate group using arcpy in 10.1. I managed to figure out how to add Access and Use Constraints and Credits to the Feature Service Definition (I'm no XML/minidom guru). Is there a way to configure the Feature Pop-ups as well, setting the pop-up title to a certain field, and the contents to another? The biggest problem is having to manually add the feature service to a map and save the map. That means typing in consistent titles, tags (which are critical for searching in the web app), and summary, and then manually entering the Access and Use Constraints and Credits before sharing the map. Can I generate a Service Definition for a whole map which includes the feature service layer? I could then enter the metadata for the map as I have for the feature layer. The basemap is not critical for this so I just allow the web app to default and then provide user options to change it. I hope this makes sense. Thanks Paul I'm posting the code snippet that deals with the Service Definitions in case it's helpful: import arcpy
import sys
import traceback
import os
import datetime
import xml.dom.minidom as DOM
try:
## The following code is adapted from code posted to the ESRI forum by Jeff Moulds, ESRI
mapDoc = mxd
sddraft = os.path.join( workspace, 'HostedMS.sddraft')
## Parse out date, city and maxCategory (eps)
categories = ["Good","Moderate","Unhealthy for Sensitive Groups","Unhealthy","Very Unhealthy","Hazardous","Hazardous"]
maxCategory = categories[maxGridCode-1]
(month, day, year, hour, minute) = parseDate(filebase)
## some date, time, city parsing / string snippet construction
sddraftSummary = "PM2.5 data from " + city + ", AK, collected on " + date + time
sddraftTags = ",".join(["PM2.5,Air Quality,Sniffer Map",city,maxCategory])
service = city + " " + date + " starting " + str(hour) + str(minute)
serverType = 'MY_HOSTED_SERVICES'
onlineDirectory = "Sniffer_Maps" # this doesn't work
tellMe("Running CreateMapSDDraft ...")
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, serverType, folder_name=onlineDirectory, summary=sddraftSummary, tags=sddraftTags)
### Returns python Dict of 'errors', 'messages', and 'warnings'
### Need to set data frame extent and projection
con = 'My Hosted Services'
workspace = os.path.dirname(workspace)
tellMe("Placing Service Definition files in: " + workspace)
sd = os.path.join(workspace,service + '.sd')
# Read the sddraft xml.
doc = DOM.parse(sddraft)
# Change service from map service to feature service
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
# Get the TypeName we want to disable.
if typeName.firstChild.data == "MapServer":
typeName.firstChild.data = "FeatureServer"
#Turn off caching
configProps = doc.getElementsByTagName('ConfigurationProperties')[0]
propArray = configProps.firstChild
propSets = propArray.childNodes
for propSet in propSets:
keyValues = propSet.childNodes
for keyValue in keyValues:
if keyValue.tagName == 'Key':
if keyValue.firstChild.data == "isCached":
# turn on caching
keyValue.nextSibling.firstChild.data = "false"
disclaimer = 'Pre-defined disclaimer'
disclaimNode = doc.createTextNode(disclaimer)
acc = doc.getElementsByTagName("AccessInformation")[0]
acc.appendChild(disclaimNode)
credits = "Pre-defined Credits"
cre = doc.getElementsByTagName("Credits")[0]
credNode = doc.createTextNode(credits)
cre.appendChild(credNode)
tellMe("Writing XML ...")
outXml = os.path.join(workspace,'HostedMSNew.sddraft')
f = open(outXml, 'w')
doc.writexml( f )
f.close()
tellMe("Running AnalyzeForSD ...")
analysis = arcpy.mapping.AnalyzeForSD(outXml)
if len(analysis['errors'])>0:
tellMe( str(analysis))
sys.exit(analysis['errors'])
#arcpy.SignOutFromPortal_server()
## tellMe("Signing In ...")
## username = "*****"
## password = "*****"
## arcpy.SignInToPortal_server(username,password,"http://www.arcgis.com/")
tellMe("Running StageService_server ...")
arcpy.StageService_server(outXml, sd)
tellMe("Running UploadServiceDefinition_server ...")
sharegroup = "Sniffer Map Feature Layer Services"
override = "OVERRIDE_DEFINITION"
arcpy.UploadServiceDefinition_server(sd, con, in_override=override, in_groups=sharegroup)
finally:
tellMe("Cleaning up scratch MXD.")
arcpy.mapping.RemoveLayer(df, lyrs[0])
mxd.save()
del mxd
... View more
10-09-2013
04:48 PM
|
0
|
6
|
796
|
POST
|
GenerateExcludeArea_management does the trick. The secret word for the tool search is "histogram".
... View more
09-20-2012
12:36 PM
|
0
|
0
|
431
|
POST
|
I'm using 10.0. Within raster layer Properties, Symbology dialog there is an option within Stretch Type to perform a percent clip from the top or bottom of the histogram. This technique works very well for what I'm doing. I have too many rasters to do this manually, but I'm unable to duplicate the effect within python. I have floating point rasters, and I want to see only the top and bottom .01 percent of each raster - 2 rasters output, 1 top and 1 bottom. I can set thresholds based on percent of the max value of the raster, but that's not nearly the same, and setting the minimum threshold based on the raster max value doesn't work well at all. The minimum value is always zero, so that's not useful at all. Does anyone know if there is a tool available to arcpy which will do this or, barring that, how arcGIS calculates that clip value so that I can try to duplicate it using python? Thanks! P.
... View more
09-19-2012
10:06 AM
|
0
|
1
|
2691
|
POST
|
That sounds strange. Script tools should pick up the geoprocessing environment settings unless you set it explicitly within the script. However, it's a huge advantage to set it in your script so you can for example, ensure your scratch workspace is a folder rather than a gdb. Any changes to these GP environment settings inside a script tool do not migrate "up" to the application, they only apply to your script. I'm wondering if your script is running "in process" or not. I wouldn't think it would make a difference. It is running in process. This is a recent install of version 10.0 though, and there are some very strange things happening with it - layer files used as symbology templates losing their symbology, entire directories disappearing from ArcMap and ArcCatalog, random inability to access any Excel files via ArcGIS - none of which happen on other computers I have tested. I wouldn't be surprised if this environment setting behavior is just another sign of a problem with this machine.
... View more
06-19-2012
09:00 AM
|
0
|
0
|
354
|
POST
|
It worked! I was surprised since the scratch workspace was already set to the correct file GDB in ArcMap, and since the raster itself already (apparently) resided in that GDB, according to ArcCatalog. I'm also going to switch to the arcpy map algebra. It feels much more intuitive to me. Thanks for introducing it to me. Paul
... View more
06-18-2012
08:48 AM
|
0
|
0
|
354
|
POST
|
I have automated a series of map making steps to generate and display 4 desired layers in ArcMap 10.0. Everything ???works??? and displays in ArcMap, but in the List By Source view my raster layer displays as sourced in: ???C:\DOCUME~1\simpsonp\LOCALS~1\Temp\???. I built the tool in ModelBuilder originally and it displayed the same behavior. When performing the steps by hand all 4 layers are listed within the same file GDB, and that is the desired behavior. Here is the Python code segment used to generate the raster layer: # Process: Natural Neighbor outpath = Output_GDB arcpy.env.workspace = outpath arcpy.gp.NaturalNeighbor_sa(v_route, pmname, v_raster ) v_raster = os.path.join(outpath, v_raster) # Process: Make Raster Layer outpath = Output_GDB arcpy.env.workspace = outpath arcpy.MakeRasterLayer_management(v_raster, v_conc) arcpy.SetParameterAsText(6, v_conc) I know MakeRasterLayer generates a virtual layer, which will be saved when the .mxd file gets saved, but I thought it would point to the raster in the Natural Neighbor step, which resides in Output_GDB, since that is the behavior of MakeFeatureLayer. We don't want anything stored on local drives, and we certainly don't want anything sent to Temp directories. What am I missing to get my Raster Layer in the right place on the TOC? Thanks Paul
... View more
06-15-2012
05:07 PM
|
0
|
4
|
2309
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|