31
What’s New for Developers in ArcGIS 10.1 Maura Daffern October 16 [email protected]

Using Python in ArcGIS 10 - Esri Canada · ArcGIS 10.1 •Maura Daffern •October 16 •[email protected] . ... These functions allow users to automate manual tasks . What’s new

  • Upload
    lamdan

  • View
    234

  • Download
    1

Embed Size (px)

Citation preview

What’s New for Developers in

ArcGIS 10.1

• Maura Daffern

• October 16

[email protected]

Today’s Agenda

This seminar is designed to help you understand:

1) Using Python to increase productivity

2) Overview of ArcGIS Runtime

Python (The Essentials)

Why Python?

Fulfills the needs of our user community

• Simple and easy to learn

• Scalable

• Modular

• Object Oriented

• Easy to maintain

• Cross platform

• Established and active user community

What is ArcPy?

ArcPy is a native Python site-package

• Includes code completion and intellisense

• Provides direct access to many ArcGIS modules

• Data access (new)

• Mapping (updated)

• Extensions - Spatial Analyst (updated)

• Network Analyst (new)

• Time (new)

Functions

The ArcPy module contains functions that are necessary for performing scripting tasks

• Listing data

• Describing data

• Geodatabase management

• Validating table and field names

• Analyzing & Updating data

• Map production

These functions allow users to automate manual tasks

What’s new in Python in

ArcGIS 10.1

Have a number of advantages over custom toolboxes

• Tools that work just like core geoprocessing tools

• Messages can be written to the results window

• A single place to edit parameter definitions, validation code, and source code)

• Implement licensing checks

• Create Value Table parameters

• Create composite data type

• i.e. A parameter than can accept a

feature layer or a raster layer

Python Toolboxes

Data Access Module

Data Access Cursors (e.g. arcpy.da.SearchCursor)

• Much faster than traditional cursors (e.g. arcpy.SearchCursor)

• Support ‘with’ statements

• No need to access the full geometry

# Import arcpy reference library import arcpy # Print the tower id, type, and the feature’s locations (lat, long) fields = [“TOWER_ID”, “TOWER_TYPE”, “SHAPE@XY”] with arcpy.da.SearchCursor (r”c:\data\utilities.gdb\towers”, fields) as cursor: for row in cursor: print (“{0},{1},{2}”.format(row[0], row[1], row[2]))

Accessing Geometry

The geometry of features can be accessed using a new “shape@” token

• Traditionally geometries slowed down the cursor since they could not be individually returned

• ‘shape@area’ , ‘shape@length’, ‘shape@xy’, ‘shape@m’, ‘shape@z’, ‘shape@trueCentroid’

# Import arcpy reference library import arcpy # Calculate the sum (length) of all the ferry lines in Canada with arcpy.da.SearchCursor(r“c:\data\transportation.gdb\ferry","shape@length") as rows: print sum([row[0]for row in rows])

Writing Feature Geometry

Insert cursors must be used to create new features

• Point and Array objects are used to create the feature parts

Update cursors can be used to replace a row’s existing geometry

# Add a new ferry line to the ferry feature class using an InsertCursor with arcpy.da.InsertCursor(r“c:\data\transportation.gdb\ferry","shape@") as ferrycursor: # Create an array using a series of point objects ptList = [arcpy.Point(-9090915.5, 5662586.6), arcpy.Point(-8916290.1, 5674228.3)] lineArray = arcpy.Array(ptList) # Create a stream polyline from the array polyline = arcpy.Polyline (lineArray) # Insert stream polyline into the dataset ferrycursor.insertRow([polyline])

Editor Class

Allows use of edit sessions and operations to manage database transactions

• Similar to editing with the GUI (Editor Toolbar)

• Edits are temporary until saved and applied to the session

fc = r“Database Connections\Brampton.sde\brampton.jgp.schools“ workspace = os.path.dirname(fc) #Start an edit session – since editing is usually tied to a specific database this variable must be provided. edit = arcpy.da.Editor(workspace) #Edit session is started without undo/redo stack for versioned data. The second arg. states whether the data is versioned. edit.startEditing(False, False) #Insert a row into the school table with arcpy.da.InsertCursor(fc, (’NAME’, ‘SHAPE@’)) as schoolcursor: schoolcursor.InsertRow([‘School of Hard Rock’, (45.5151, -79.85858)]) # Stop the edit session and commit the changes to the table edit.stopEditing(True)

Python Add-ins

What is an Add-in?

An add-in is a customization such as a collection of tools that plugs into ArcGIS Desktop

• Introduced at 10.0 to make it easier for users to extend ArcGIS

• Can be authored using .NET Language & JAVA (ArcGIS 10.0)

• ArcGIS 10.1 introduces python to the list of supported languages

Python Add-in Wizard

Introduced to streamline the add-in creation process

• Download available from the ArcGIS Resources Center http://bit.ly/pythonwizard

• Specify what product it’s for

• Project properties can be defined easily within the wizard

• Creates all of the directories and files required for the add-in to work

• Button – Simple click to execute

• Tool – Requires user interaction

• Combo Box – Provide a set of choices

• Menu – Container for buttons or other menus

• Toolbar – Container for every add-in type

• Tool Palette – Container of tools

• Application Extension

• Coordinates activities between other components – i.e. If an extension is not enabled then the related series of tools will not be enabled

Types of Python Add-ins

Demonstration

• Python resource center

• Creating a python toolbox

• Creating a python add-in

ArcGIS Runtime SDK for

WPF

Why ArcGIS Runtime?

ArcGIS Runtime SDK for WPF enables developers to build rich, highly functional GIS applications

• Applications with small memory and disk-space footprints

• Build touch-screen applications

• Leverage device gps (Location Aware device)

• Exploit the performance of the operating system

• Integrate with the ArcGIS system

Map

Display

GPS

Geocoding

Geoprocessing Python

Scripting

Network

Analyst Spatial

Analyst

3D

Analyst

ArcGIS Runtime (The Details)

New Architecture

• Native 32 and 64 bit code execution

• Asynchronous programming enables true multi-threading

Simplified Deployment

• No Install required

• Deploy only needed components

• Side-by-Side deployment

• Independent of other ArcGIS installs

Getting Started

The Runtime is can be accessed through the Esri Developer Network (EDN)

After installing the SDK you’re provided with

• Central ArcGIS Runtime

• API Assemblies

• Samples

• Conceptual / API Reference Documentation

• VS 2010 / Blend 4 integration

Creating a WPF Application

1

2

3

4

5

1) Project Template Directory

2) ArcGIS Templates (WPF, ArcObjects, Desktop Add-Ins, SOEs)

3) WPF Map Application

4) Screenshot of template application

5) Details about the project and where the solution will be stored

ArcGIS for Desktop is used to provide a solution

Content is Authored

• Map Packages

• Tiles Packages

• Locator Packages

Functionality can be authored

• Geoprocessing Packages

Packages can be delivered on media or downloaded from online

ArcGIS for Server can deliver content directly to clients

It’s Not Just About Code

Plan Map Content

Map

• Buttons

Live / Temporary Data

• Vehicles, events, query results...

Operational Data

• Facilities, zones, networks…

Basemap

• Imagery, topographic data…

Identify Operations

Attribute and spatial queries

Handled by specific task classes in the ESRI.ArcGIS.Client.Task namespace

Similar programming pattern for each task

• Define input parameters

• Execute task asynchronously

• Process and display results

Querying data

Editing

Geodatabase Feature Editing

• File and SDE Geodatabase

• Simple feature editing

• Attributes and shape

Supported by Feature Services

Edit environment authored in ArcGIS for Desktop

Geoprocessing

Tools, Scripts, and Models Supported

System Tools Available depending on the level of the runtime

• Basic (None)

• Standard (ArcEditor level tools)

• Some tools require Standard level + Extension

• Tool list available

The analyzers at 10.1 help to improve the service publishing workflow

Demonstration II

• ArcGIS Resource Center

• IDE Integration

• WPF Sample Editing

Summary

In this seminar you were introduced to:

1) Using Python to increase productivity

2) Overview of ArcGIS Runtime

Python Resources

ArcGIS Resources Center

• http://resources.arcgis.com/

Using Python Help

• http://resources.arcgis.com/en/communities/python/

ArcGIS Python Recipes

• http://arcpy.wordpress.com/

twitter.com/EsriCanada facebook.com/EsriCanada