liste

Bonjour et bienvenue dans mon site ! Willkommen auf meiner Seite! welcome in my homepage! http://assistance-en-sig.blogspot.com/ SIG ; Bases de données ; Géomatique; Python; ArcGIS; QGIS;

recherche

Showing posts with label Scripting. Show all posts
Showing posts with label Scripting. Show all posts

Sunday, November 10, 2013

Python script for running ArcGIS10 Area Solar Radiation tool

I am trying to run the Area Solar Radiation tool using a Python script, because I want to run it on several DEMs at once. I am using a server with Windows 7, ArcGIS 10 and PyScripter.
I am a beginner with Python and ArcGIS and for some reason my script doesn't work. In most of my attempts I end up with an error saying that there is a problem with executing AreaSolarRadiation. When I try running it on only one DEM it runs OK, but the outputs are empty files.
My guess is that there is some problem either with the glob command, the outGlobalRad.save command, or simply with the solar radiation command. But really I have no clue.
I'd be very grateful for any corrections/advice on how to deal with this! Thanks! JJ
This is my script:
#Name: AreaSolarRadiation_example02.py
#Description: Derives incoming solar radiation from a raster surface.
#Outputs a global radiation raster and optional direct, diffuse and direct duration rasters
#for a specified time period. (April to July).
#Requirements: Spatial Analyst Extension
#Author: ESRI


#Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

#Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

#To run on many shapefiles in one folder
import glob

#Set environment settings
env.workspace="Z:/Personal/MyDropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/PolygonToRaster/"

   folder="Z:/Personal/MyDropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/PolygonToRaster/"


# Set local variables
inRaster = name
latitude = 51
skySize = 200
timeConfig = TimeMultipleDays(2008, 5, 160)
dayInterval = 14
hourInterval = 0.5
zFactor = 1
calcDirections = 32
zenithDivisions = 16
azimuthDivisions = 16
diffuseProp = 0.7
transmittivity = 0.4
outDirectRad = ""
outDiffuseRad = ""
outDirectDur = ""
#outDirectRad = Raster("Z:/Personal/My Dropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/AreaSolRad/outDirectRad")
#outDiffuseRad = Raster("Z:/Personal/My Dropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/AreaSolRad/outDiffuseRad")
#outDirectDur = Raster("Z:/Personal/My Dropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/AreaSolRad/outDirectDur")


# Execute AreaSolarRadiation
outGlobalRad = AreaSolarRadiation(inRaster, latitude, skySize, timeConfig, dayInterval, hourInterval, "NOINTERVAL", zFactor, "FLAT_SURFACE", calcDirections, zenithDivisions, azimuthDivisions, "UNIFORM_SKY", diffuseProp, transmittivity, outDirectRad, outDiffuseRad, outDirectDur)

# Save the output
outGlobalRad.save("Z:/Personal/MyDropbox/GISwork_DQ_JJS/Analysis/UK/Results/microRep/GISoutput/AreaSolRad/outGlobalRad.tif")

Monday, April 8, 2013

Lesson 1:Introduction to GIS modeling and Python


Overview

Welcome to Geography 485. Over the next ten weeks you'll work through four lessons and a final project dealing with ArcGIS automation in Python. Each lesson will contain readings, examples, and projects. Since the lessons are two weeks long, you should plan between 20 - 24 hours of work to complete them, although this number may vary depending on your prior programming experience. See the Course Schedule section of this syllabus, below, for a schedule of the lessons and course projects.
As with GEOG 483 and GEOG 484, the lessons in this course are project-based with key concepts embedded within. However, because of the nature of computer programming, there is no way this course can follow the step-by-step instruction design of the previous courses. You will probably find the course to be more challenging than the others. For that reason, it is more important than ever that you stay on schedule and take advantage of the course message boards and private e-mail. It's quite likely that you will get stuck somewhere during the course, so before getting hopelessly frustrated, please seek out help from me or your classmates!
I hope that by now that you have reviewed our Orientation and Syllabus for an important course site overview. Before we begin our first project, let me share some important information about a related ESRI course.

ESRI Virtual Campus Courses Using Python in ArcGIS Desktop 10 

There is a free Esri Virtual Campus course Using Python in ArcGIS Desktop 10 that introduces a lot of the same things you'll learn this quarter in Geog 485. The course consists of a one-hour recorded seminar and a walkthrough exercise. If you want to get a head start, or you feel you want some reinforcement of what we're learning from a different point of view, it would be worth your time to complete this Virtual Campus course.
All you need in order to access this course is an Esri Global Account, which you can create for free. You do not need to obtain an access code from Penn State.
The video moves very quickly and covers a range of concepts that we'll spend 10 weeks studying in depth, so don't worry if you don't understand it all immediately. You might find it helpful to watch the video again near the end of Geog 485 to review what you've learned.

Questions?

If you have any questions now or at any point during this week, please feel free to post them to the Lesson 1 Discussion Forum. (To access the forums, return to ANGEL via the ANGEL link in the Resources menu. Once in ANGEL, you can navigate to the Communicate tab and then scroll down to the Discussion Forums section.) While you are there, feel free to post your own responses if you, too, are able to help out a classmate.
Now, let's begin Lesson 1.

Python Scripting for ArcGIS


Book Description

January 9, 2013  1589482824  978-1589482821 Pap/DVD
Python Scripting for ArcGIS is a guide to help experienced users of ArcGIS® for Desktop get started with Python® scripting. This book teaches how to write Python code that works with spatial data to automate geoprocessing tasks in ArcGIS. Readers can thus learn the skill set needed to create custom tools. The book contains 14 chapters, with the corresponding data and exercises on the accompanying DVD. A 180-day trial of ArcGIS 10.1 for Desktop software is also provided as an online download.

Key topics in this book include:
  • Python language fundamentals
  • Automating geoprocessing tasks
  • Exploring and manipulating spatial data
  • Working with geometries and rasters
  • Map scripting
  • Debugging and error handling
  • Creating functions and classes
  • Creating and sharing script tools
More details on the book can be found at the Esri Press website: esriurl.com/5564. This includes sample chapters for download. Instructor who are considering the book as a textbook for a course can request a deskcopy from Esri Press: esripress.esri.com/offers/deskcopy.