|
POST
|
Hi All, Please provide your suggestion to solve this issue. i still stuck
... View more
03-07-2017
09:58 PM
|
0
|
5
|
3097
|
|
POST
|
Hi @joshua Bixby, I am reposting my code along with my NetCDF data file which link is given below. Because of overlimit i could not attach NetCDF file directly, NetCDF file link : Dropbox - spei01.nc When i running below script, there is only single raster generating as name newfolder import os, sys
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
# Script arguments
netCDF = "C:\\Users\\Downloads\\SPIE"
rainfall = "C:\\Users\\Downloads\\SPIE\\New folder"
arcpy.env.workspace = netCDF
# Read Date from csv file
eveDate = open ("C:\\Users\\Downloads\\SPIE\\name1.csv", "r")
headerLine = eveDate.readline()
valueList = headerLine.split(",")
dateValueIndex = valueList.index("Date")
eventList = []
for line in eveDate.readlines():
segmenLine = line.split(",")
variable = "spei"
x_dimension = "lon"
y_dimension = "lat"
band_dimension = ""
valueSelectionMethod = "BY_VALUE"
outFile = "Pre"
# extract dimensionValues from csv file
arcpy.MakeNetCDFRasterLayer_md("spei01.nc", variable, x_dimension, y_dimension, outFile, band_dimension, segmenLine[dateValueIndex], valueSelectionMethod)
print "layer done"
#copy and save as raster tif file
arcpy.CopyRaster_management(outFile, rainfall + segmenLine[dateValueIndex] + ".tif" , "", "", "", "NONE", "NONE", "")
print "raster done"
... View more
03-07-2017
07:31 PM
|
0
|
1
|
3097
|
|
POST
|
Actually i am trying to extract one year data from time series netCDF file. My NetCDF file contain monthly data from 1901-2014. So i need to extract the monthly data for different year and make it as raster map. And i removed the second loop, line no 27 and 28, but problem is same. Now also i am getting the single output as name of output "newfolde". Why such type of output and output's name occurring?. Please guide us to solve this issue. Why this script not looping all the date value and not make any raster which i have in csv file?
... View more
03-07-2017
07:53 AM
|
0
|
3
|
3097
|
|
POST
|
@joshua Bixby, Thank you. I have corrected my csv file, as replaced in line series all the date value, after the correction of my csv file , script is running without any error but i am getting only single output as newfolder name. Now what should i do to loop through all the date range which i have in csv file I have mentioned date range in csv file, like. Date 2010-01-16 2010-02-16 2010-03-16 2010-04-16 2010-05-16 2010-06-16 2010-07-16 2010-08-16 2010-09-16 2010-10-16 2010-11-16 2010-12-16
... View more
03-07-2017
07:07 AM
|
0
|
5
|
3097
|
|
POST
|
Hi All, I have one NetCDF file, that contain monthly value for the different year (1910 - 2014). I want to extract few years data (e.g 2000 - 2014), date range reading from a csv file and save it as a raster map as the name format of year-month-date. I am working on below script but I am getting error Below i have attached the csv file which i am using for date range purpose. Any help would be greatly appreciated! Thanks The image showing the format of Year-month-date Error massage Traceback (most recent call last):
File "<module4>", line 18, in <module>
ValueError: 'Date' is not in list Here what i have so far import os, sys
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
# Script arguments
netCDF = "C:\\Users\\Downloads\\SPIE"
rainfall = "C:\\Users\\Downloads\\SPIE\\New folder"
arcpy.env.workspace = netCDF
# Read Date from csv file
eveDate = open ("C:\\Users\\Downloads\\SPIE\\Name1.csv")
headerLine = eveDate.readline()
valueList = headerLine.split(",")
dateValueIndex = valueList.index("Date")
eventList = []
for line in eveDate.readlines():
segmenLine = line.split(",")
variable = "spei"
x_dimension = "lon"
y_dimension = "lat"
band_dimension = ""
for year in range(2010):
nc_name = 'spei.%d.nc' % (year,)
valueSelectionMethod = "BY_VALUE"
outFile = "Pre"
# extract dimensionValues from csv file
arcpy.MakeNetCDFRasterLayer_md("spei.nc", variable, x_dimension, y_dimension, outFile, band_dimension, segmenLine[dateValueIndex], valueSelectionMethod)
print "layer done"
#copy and save as raster tif file
arcpy.CopyRaster_management(outFile, rainfall + segmenLine[dateValueIndex] + ".tif" , "", "", "", "NONE", "NONE", "")
print "raster done"
... View more
03-07-2017
06:12 AM
|
0
|
13
|
5255
|
|
POST
|
Dan Patterson, Thank you very much. Finally, I reached to the end using below Script, for ras_num in [str(i).zfill(3) for i in range(1, 13)]:
ras_Prcep = getRasterFromList(ras_num, lst_ras_Prcep, ws_in_Prcep)
ras_RD = getRasterFromList(ras_num, lst_ras_RD, ws_in_RD)
if all([not ras_Prcep is None, not ras_RD is None]):
# calculate
ras_E1A = (ras_Prcep * ras_RD) * ((Square(ras_Prcep)) + (Square(ras_RD) + ras_Prcep * ras_RD))
ras_E1B = ras_Prcep + ras_RD * ((Square(ras_Prcep)) + (Square(ras_RD)))
ras_AET = ras_E1A / ras_E1B
# save raster
out_name_AET = os.path.join(ws_out_AET, 'r{0}_AET.TIF'.format(ras_num))
ras_AET.save(out_name_AET)
print out_name_AET
... View more
02-22-2017
06:06 AM
|
0
|
0
|
2064
|
|
POST
|
Thank you for the suggestions. Again I have updated my full code. I think multiple sequence might be possible here. Please request to all cooperate with us to solve this issue.
... View more
02-21-2017
10:39 PM
|
0
|
2
|
2064
|
|
POST
|
Hi, I am trying to execute an equation into python program considering monthly folder, but I am getting error, Below i have attached reference of the equation also, Where P and R for rasterlist1 and rasterlist2 respectively, Error message is. Traceback (most recent call last):
File "<module3>", line 23, in <module>
TypeError: can't multiply sequence by non-int of type 'list' Script i am working, import arcpy, os, calendar
import numpy
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
topWorkspace = r'D:\NPP_GUJARAT_MONSOON'
ws_out = r'D:\NPP_GUJARAT_MONSOON\EVA3'
arcpy.env.workspace = topWorkspace
months = {calendar.month_name[i].upper(): str(i).zfill(3) for i in range(1, 13)} # Get dict of months and month number (i.e. January = 001, March = 003 etc.)
# Step through list of all folders
for folderPath in arcpy.ListWorkspaces():
baseName = os.path.basename(folderPath).upper()
if baseName in months: # Test that subfolder is a month name
monthNumber = months[baseName] # Get month-number for use in output filename
arcpy.env.workspace = folderPath
# list rasters (Erlier:*Max_Temper.tif, We changed it to below)
rasterList1 = arcpy.ListRasters('Precipitat*.tif')
rasterList2 = arcpy.ListRasters('Solar*.tif')
print rasterList1, rasterList2
for ras_name in rasterList1:
ras_mean = arcpy.Raster(os.path.join(folderPath, ras_name))
for ras_name in rasterList2:
ras_mean = arcpy.Raster(os.path.join(folderPath, ras_name))
outCellStatistics = ((rasterList1 * rasterList2) * ((Square(rasterList1)) + (Square(rasterList2)) + rasterList1 * rasterList2)) /rasterList1 + rasterList2 * ((Square(rasterList1)) + (Square(rasterList2)))
#Save the output
outRasterName = os.path.join(ws_out, "EO_{}.tif".format(monthNumber))
outCellStatistics.save(outRasterName)
print outRasterName
#print done
print 'done'
... View more
02-21-2017
12:30 PM
|
0
|
6
|
3369
|
|
POST
|
Dan_Patterson, Thank you very much. Now problem is resolved
... View more
02-21-2017
08:19 AM
|
0
|
0
|
1429
|
|
POST
|
Dear All, Please can anyone help me, how to fill the no data value in raster, I have tried it using below equation but output raster not any changed. My raster resolution is 250 m. Here-With i am trying to fill the white line Thank you. Con(IsNull("raster"), FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEAN"), "raster")
... View more
02-20-2017
11:45 PM
|
0
|
2
|
2457
|
|
POST
|
Dan_Patterson I am also very interested to know the same answer, Actually here user performing interpolation of temperature data, while he trying to execute condition file as topography because temperature profile is changing according to height of topography. So how we can put the topography as a condition raster while performing Interpolation.
... View more
02-01-2017
09:56 PM
|
1
|
0
|
3149
|
|
POST
|
Dan Patterson Xander Bakker, Sorry for the late reply. I was out of station. Thank you very much. Script is perfect working. Xander Bakker As you mentioned the UNIT seems to be invalid, Actually I tried to assign the unit my own "gram carbon per square meter (gcsqm) " Howover it's not taking as a valid UNIT so I changed it to "Gram" now it's working perfectly. xander_bakker i have one more request, can we convert those NetCDF as a time dimension single NetCDF ? Once again thanks to all for your valuable contribution to solve the issue.
... View more
01-26-2017
09:57 AM
|
0
|
2
|
1047
|
|
POST
|
Dan_Patterson xander_bakker, can it be make a time series NetCDF (using my 12 months raster) using arcPy???
... View more
01-21-2017
01:05 AM
|
0
|
0
|
1957
|
|
POST
|
Dan_Patterson xander_bakker @Lan Murry , i have tried in my best to do it but i won't understanding the which way i have to solve the issue to make the time series NetCDF
... View more
01-21-2017
12:44 AM
|
0
|
0
|
1957
|
|
POST
|
I have posted my updated code reply with @Lan Murry comment. and that Stake overflow code is not posted by me , I mostly using geonet. My one of research junior also trying to solve the same issue. Thank you.
... View more
01-21-2017
12:40 AM
|
0
|
1
|
1957
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-01-2017 09:56 PM | |
| 1 | 01-19-2017 08:03 AM | |
| 1 | 07-31-2017 11:57 AM | |
| 1 | 08-25-2016 09:38 AM | |
| 1 | 08-17-2016 11:13 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:25 AM
|