2

I want to use ArcGIS Point Solar Radiation tool to compute the solar radiation for more than 1000 data points. The table for the shapefile point data looks like this:

enter image description here

Hour represent the time of start and ending time of collection. The julian column is the julian day.

I believe ArcGIS provides the code below to work for one row only:

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

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "elevation"
inPntFC = "observers.shp"
outFeatures = "c:/sapyexamples/output/outglobal1.shp"
latitude = 35.75
skySize = 200
timeConfig = TimeWithinDay(183, 16, 16)
dayInterval = 14
hourInterval = 0.5
zFactor = 0.3048
calcDirections = 32
zenithDivisions = 8
azimuthDivisions = 8
diffuseProp = 0.3
transmittivity = 0.5
outDirectRad = "C:/sapyexamples/output/outdirectrad1.shp"
outDiffuseRad = "C:/sapyexamples/output/outdiffuserad1.shp"
outDirectDur = "C:/sapyexamples/output/outduration1.shp"

# Execute PointsSolarRadiation...
PointsSolarRadiation(inRaster, inPntFC, outFeatures, "", latitude, skySize, 
                     timeConfig, dayInterval, hourInterval, "INTERVAL", 
                     zFactor, "FROM_DEM", calcDirections, zenithDivisions, 
                     azimuthDivisions,"STANDARD_OVERCAST_SKY", diffuseProp, 
                     transmittivity, outDirectRad, outDiffuseRad, outDirectDur)  

How could I edit the code so that it would calculate the solar radiation per row (or per point sample)?

I want to keep most of the values constant, except for:

timeConfig = TimeWithinDay(183, 16, 16)

That means that in every run, it will only change the 'Julian' day and the 'hour' and keep the rest of the values the same. For example: (183, 16, 16) should be (269, 18, 18) when the code runs to calculate the third row.

In the end, once all the rows are calculated, a new column would be added for the solar radiation of each row.

I am new to coding.

  • When you want to do something per row in a table, put it inside an arcpy.da.SearchCursor (see examples): pro.arcgis.com/en/pro-app/arcpy/data-access/… – phloem Jan 25 '17 at 5:50
  • Thank you @phloem for the response. However, I am wondering how SearchCursor could be integrated in the code above. I would appreciate it if you can shed me some light. – GISnew Jan 25 '17 at 6:42
  • You would create a search cursor, passing in the column values you want to be dynamic (Julian day and hour), and run solar radiation inside (once per row). Since you want to update a column in the feature class you're reading, you may want to use an arcpy.da.UpdateCursor (it can read and write, while search cursor only reads), but it functions similarly (one call per row). – phloem Jan 25 '17 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.