Giter Club home page Giter Club logo

arcgis-admin-python-scripts's Introduction

##Introduction This repo will hold a set of Python 3 scripts leveraging our new ArcGIS Python Beta API to perform various administrative tasks by an admin. More scripts will be added in the near future, and everyone with access to this repo is encouraged to contribute to it.

##Requirements and Installation

To run the script you'll need to install the following dependencies.

Note: There is no universal installation of Python 3 currently so you will have to be sure that you're calling the exact same version of python 3 where you installed the ArcGIS Beta API. Using the command which python3 will return the path to your current default python 3, and is a useful tool for verifying. The python 3 version you want to use for this script should be in your /anaconda/bin directory, similar to below.

bash-3.2$ which python3
/Users/<user_name>/anaconda/bin/python3

##Preparing your MetaData for update

  1. Log in to your ArcGIS site. e.g. http://www.arcgis.com
  2. Click on the username dropdown in the upper right corner.
  3. Click on your username to be taken to your user profile page.
  4. Click on 'My Content' at the top of the page and you will be shown a view of all your items similar to the example photo below. alt text
  5. Click on an item to view a detailed page for that item.
  6. On the right hand side of the page you should see see a set of buttons, some with dropdown funtionality. alt text
  7. Click the Metadata dropdown, and then choose "edit"
  8. Click the "Save Local Copy" button to download the metadata in the form of an xml file for that item.
  9. Copy the metadata xml file(s) to the same directory as the UpdateMetaPy3.py file. alt text
  10. Open the metadata in your editor of choice, being careful not to edit the <mdFileID> field at all.
  • In the screenshot below I've changed the title of the metadata by removing the '2015' from the yellow circled field.
  • The field in the red circle should not be changed as it's the canonical id for the item in ArcGIS online, and is what the script uses to find the item online. alt text

##Run the update script

####updateMetaPy3.py This script will look through all files in a directory and if any valid metadata files are available, it will update that respective item in ArcGIS Online with the local metadata file. When completed it will produce 2 files. report.csv is a list of the ArcGIS Online items and times they were updated. errors.csv is a list of the files in the directory that were not valid metadata and the error message. This is for python 3 and makes use of the ArcGIS Python Beta API

flags scripts accepts:

  • -a this flag specifies sets the GIS you want to administer [required]
  • -u this flag sets the username to log in with [required]
  • -p this flag sets the password associated with the username [required]

##Example python3 updateMetaPy3.py -u <username> -p <password> -a https://www.arcgis.com

Once the script is completed. Refer to step 7 above but instead of clicking edit, this time click view to observe your changes. Below are two screenshots of the metadata pre and post edit. alt text

####Python 2 support Where possible I will try to include Python 2 versions of the scripts using the ArcGIS rest api and fairly generic functions, but support for Python 2 is not guaranteed moving forward, and using our new Python 3 API is highly encouraged.

####updateMetaPy2.py This script will look through all the files in a directory and if any valid metadata files are available, it will update the respective item in agol with that metadata file. When completed, it will produce 2 files. report.csv is a list of the items and times they were updated. errors.csv is a list of the files in the directory that were not updated and the error message. This is for python 2 and aside from the requests package every library it uses is included in the python standard library.

####Required to run:

  • Python 2

    #####Example python updateMetaPy2.py -u <username> -p <password> -a https://www.arcgis.com

##Contributing

Contributing to Esri Open Source Projects

Esri welcomes contributions to our open source projects on Github.

##Issues

Feel free to submit issues and enhancement requests.

Please refer to each project's style guidelines and guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

##Licensing Copyright 2016 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license file.

[](Esri Tags: Python ArcGIS API XML Metadata Administration) [](Esri Language: Python)

arcgis-admin-python-scripts's People

Contributors

marvinperry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

arcgis-admin-python-scripts's Issues

Suggestions for improvement - mdBulkEdit.py

@MarvinPerry
Nice jobs on the scripts - very useful. I went through mdBulkEdit.py and made some notes / suggestions that could help future users:

Documentation improvement

  • As this repo grows and more scripts are introduced, it would be helpful for the scripts to have their own folders with their own README. The main README would be a landing page that directs users to the individual script folders.
  • Step by step instructions for running the script and what to expect would be very useful.
  • Users must download python3 from Anaconda, as this is what the ArcGIS Python API requires. Regular python3 doesn't work.
  • Users can either clone the repo or copy the script of interest into a text editor and save it in their specified directory.
  • Users must have navigated to the directory with the script in order to run it.
  • <username> is case sensitive.
  • This script will only pull items that are shared publicly.
  • Currently only works with ISO 19139 Metadata Implementation Specification (administrators need to set this as their default metadata standard in their org settings).
  • It would be helpful to know what the script will generate -- metaDataTable.csv and an XML file for each item.
  • When having to run the -c script a second time, the message to the user should explain why.

For the CSV file:

  • Which columns in the CSV file should the user not edit? mdFileID?
  • resTitle should be the first column
  • Why don't we include all fields from the metadata standard in the CSV?
  • A key is required for users to understand what the fields are, or the fields should be human readable / match the XML online.
  • Certain fields require certain types of input, eg date fields need to be in date format.

Script improvement/extensions

  • Work on all publicly shared services regardless of license.
  • Work for all metadata standards on AGOL (FGDC CSDGM, INSPIRE, ISO 19139 GML3.2, North American Profile of ISO19115 2003).
  • A user can point the script to only access a particular folder within their ArcGIS Online content.
  • A user can point the script to only access a particular group within their ArcGIS Online organization.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.