POST
|
Zing!!! Love it. We just moved a whole Bureau off of them.
... View more
08-06-2015
10:52 AM
|
0
|
0
|
582
|
POST
|
Sure! How about: def gdbInUse(input_file_geodatabase):
"""
Determine whether any lock files exist in a file geodatabase
Returns boolean output - True or False
"""
arcpy.env.workspace = input_file_geodatabase
lockList = arcpy.ListFiles("*lock*")
if lockList:
return True
else:
return False ? I'm thinking this could then be implemented in a script tool or extension using ArcObjects. Update: for an individual dataset, arcpy has a handy tool called Test Schema Lock that will return True if a schema lock can be acquired for a feature class, feature dataset, or table. Disclaimer: I'm not sure how this would work with personal geodatabase but I believe a similar method could be used to identify the record locking file that appears in the same folder as the .mdb when it is in use. I forget the extension for that type of file but have noticed it before when looking at a personal geodatabase in Windows explorer. Micah PS You had me at shrubbery.
... View more
08-06-2015
10:44 AM
|
3
|
3
|
582
|
POST
|
Greetings, Is it possible to "open" a service definition file (.sd) using arcpy, ArcGIS REST API, or some other method? I have a number of .sd files which I'd like to interrogate for their properties. I'm mainly interested in seeing what data sources went into the service definition. I can do this with running services using the ArcGIS REST API but I am not clear on how to access the properties of a service definition file. Thanks for any help you can provide! Warm Regards, Micah Babinski
... View more
07-24-2015
02:45 PM
|
2
|
0
|
3000
|
POST
|
Great, thank you Andrew! I imagine the URL parameter info will be particularly useful as we go forward. My colleague and I took some time to register each individual feature layer in AGOL and added to the Open Data group, so now we have finer control over tags and thumbnails. Would this cause problems down the road if we should decide to add layers to the Open Data service, re-ordering the index numbers of the layers? I'm still interested in querying by individual group; any additional info on that you could pass along would be fantastic. Warm Regards, Micah
... View more
07-17-2015
08:26 AM
|
0
|
0
|
580
|
POST
|
Greetings Jose, A while back I developed a custom script tool which could be used in ModelBuilder to reorder the fields in a shapefile. The tool uses the GDAL/OGR library from OSGeo4W. If you are interested in diving in to custom Python script tools and open source, let me know and I can share my script. Micah
... View more
07-14-2015
10:06 AM
|
0
|
0
|
640
|
BLOG
|
Well done! I'm a huge geonet fan. It's a great resource for people working with Esri software.
... View more
07-13-2015
08:05 AM
|
1
|
0
|
1938
|
POST
|
Greetings, I have two questions: 1. Is there a way to register an on-premises map service with AGOL in a way that each feature layer is individually added, so that they may be given individual tags? 2. How are organizations controlling which datasets are assigned to thematic categories within their site? Background: I've been tasked with setting up my agency's ArcGIS Open Data site. I'd like to know how other organizations organize their Open Data content so that it is "discoverable" and not too time-consuming to manage. I've published an Open Data service on our on-premises ArcGIS Server, registered the service with AGOL and added it as an item to our Open Data group, and in turn added that group to the Open Data site. 1. Now the datasets are showing up on the Open Data site (still Private while in development), but since the AGOL item is a "map image layer," each layer has the same tags - the ones provided for the service: As you can see the feature layer description came through but the tags are service-level tags. I'd like to give each layer tags specific to that layer (we maintain these in a SQL Server database). I've experimented with registering individual feature layers from the open data service in AGOL but I'm worried that if the index of the layer changes when I republish the service that the connection may break, and then with 75+ layers to add this will be very time consuming. So, is there a way to register a service with AGOL in a way that each feature layer is individually added, so that they may be given individual tags? 2. I've created ten text widgets in the Open Data site, each with a link leading to a formatted url that queries the category name: (Boundary is http://data.pdx.opendata.arcgis.com/datasets?q=boundary&sort_by=relevance) So, how do I structure the tags, metadata, etc for the particular layers so that only the desired layers show up under a search of "boundary?" Thanks, Micah
... View more
07-10-2015
12:19 PM
|
1
|
2
|
4332
|
POST
|
Greetings Nolan, A couple questions for you: 1. Does the service you'd like to overwrite have "Feature Access" enabled? In other words, does it need to be editable? 2. Is the service you'd like to overwrite published on your own on-premise ArcGIS Server, or on Esri's "My Hosted Services?" For an on-premise map service that does not require feature access, the following script (set up for a script tool but could be modified to be run stand-alone outside of ArcGIS), should get you there: # overwrite_service.py
# Created: 3/11/2015
# Author: Micah Babinski
# City of Portland
# Bureau of Technology Services
# micah.babinski@portlandoregon.gov
# 503.823.1091
#
# Description: Overwrites an existing map service on ArcGIS Server
#
import arcpy
import xml.dom.minidom as DOM
# User parameters
map_document = arcpy.GetParameterAsText(0)
service_folder = arcpy.GetParameterAsText(1)
service_name = arcpy.GetParameterAsText(2)
# Create the MXD object and define the summary and tags
arcpy.AddMessage("Creating an MXD object and retrieving the summary and tags.")
mxd = arcpy.mapping.MapDocument(map_document)
summary = mxd.summary
tags = mxd.tags
# Define the workspace path
arcpy.AddMessage("Defining the workspace path.")
workspace = arcpy.Describe(map_document).path + "\\"
# Define the AGS connection
arcpy.AddMessage("Defining the AGS connection file.")
con = #r"Path to your arcgis server connection eg: GIS Servers\arcgis on myserver_6080 (admin)"
# Create a variable representing the output service definition draft
sddraft = workspace + service_name + '.sddraft'
# Create a variable representing the output service draft
sd = workspace + service_name + '.sd'
# Create service definition draft
arcpy.AddMessage("Creating the service definition draft.")
analysis = arcpy.mapping.CreateMapSDDraft(mxd, sddraft, service_name, 'ARCGIS_SERVER', con, False, service_folder, summary, tags)
# Set service type to esriServiceDefinitionType_Replacement
arcpy.AddMessage("Setting the service type to be a replacement.")
newType = 'esriServiceDefinitionType_Replacement'
xml = sddraft
doc = DOM.parse(xml)
descriptions = doc.getElementsByTagName('Type')
for desc in descriptions:
if desc.parentNode.tagName == 'SVCManifest':
if desc.hasChildNodes():
desc.firstChild.data = newType
outXml = xml
f = open(outXml, 'w')
doc.writexml( f )
f.close()
# Stage and upload the service if the sddraft analysis did not contain errors
if analysis['errors'] == {}:
# Execute StageService
arcpy.AddMessage("Staging the service.")
arcpy.StageService_server(sddraft, sd)
# Execute UploadServiceDefinition
arcpy.AddMessage("Uploading the service.")
arcpy.UploadServiceDefinition_server(sd, con)
arcpy.AddMessage("Upload successful!")
else:
# If the sddraft analysis contained errors, display them
arcpy.AddMessage("The following errors prevented overwriting of the service:")
arcpy.AddMessage(analysis['errors'])
# Remove the sd draft and sd files
arcpy.AddMessage("Cleaning up.")
arcpy.Delete_management(sd)
arcpy.Delete_management(sddraft) Now if you need feature access, it gets more complicated . I haven't figured out how to overwrite an on-premise editable feature service with Python yet, but I have asked about it on geonet. For overwriting an Esri-hosted feature service, there is a code sample here, but I haven't tested it yet. If you figure out how to overwrite the on-premise editable service, PLEASE let me know. Happy scripting! Micah
... View more
06-04-2015
07:21 AM
|
3
|
3
|
2864
|