POST
|
I was just able to replicate the same problem. The solution was to alter the workflow and use rasters as the input zones. I was previously using shapefiles as the zones. Windows 7 64-bit ArcGIS 10.1, SP1, 64-bit Background Processing Patch
... View more
11-14-2013
10:47 AM
|
0
|
0
|
498
|
POST
|
Thanks Eric. I'm not sure why I chose to use templates originally; this is a project I've put down and picked up several times. Luckily it's a trivial update on my end.
... View more
08-01-2013
05:52 AM
|
0
|
0
|
220
|
POST
|
I'm using AGD 10.1 and playing around with some workflows for automating interpolation in a Python script. For a series of EBK models, I was using the Incremental Spatial Autocorrelation tool to calculate a distance band, and setting the MajorSemiaxis of my search neighborhood in a template XML file. I happen to notice that the EBK tool auto-populated the same value when I ran it in ArcMap. Does GA use Incremental Spatial Autocorrelation behind the scenes to create a default values for a search neighborhood? If so, does it do this for all interpolation tools (IDW, EBK, etc.)? Sorry if this is documented somewhere. I couldn't find an answer on my own.
... View more
07-31-2013
05:26 AM
|
0
|
2
|
2892
|
POST
|
It's not a quick-and-easy solution to your problem, but if you've installed pywin32 and some version of Excel, you just use the COM interface to Excel. Open PythonWin Click "Tools" and select "COM Makepy utility" Look for something like "Microsoft Excel 12.0 Object Library" and click "OK" Now you can access Excel directly through a Python script like so: import win32com.client xl = win32com.client.Dispatch('Excel.Application') xl.Visible = 1 wb = xl.Workbooks.Add() datasheet = wb.Worksheets.Add() datasheet.Name = 'New name for my worksheet' datasheet.Cells(1, 1).Value = 'This is cell A1' datasheet.Cells(2, 2).Value = 'This is cell B2' wb.SaveAs('C:\\Temp\\example.xlsx') wb.Close(SaveChanges=1) xl.Quit() del xl The documentation for accessing Excel this way is scattered, but I've scripted the processing and creating of hundreds of spreadsheets and Excel charts this way.
... View more
07-30-2013
12:36 PM
|
0
|
0
|
2388
|
POST
|
This is very easily done. You can read a little about SearchCursors here, and about writing to text files with Python here (page down to section 7.2 Reading and Writing Files. The general pattern for this operation in AGD 10.0 is something like this: import arcpy as ap # this is how you create a file in Python myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w') # create a row object to navigate your table rows = ap.SearchCursor('C:\\temp\\myInputTable.shp') row = rows.next() # for each row in your table, retrieve the value in the 'APN' field, convert it # to a string, write it to your output file, then move to the next line in both # your input table and output file for row in rows: myOutputFile.write(str(row.APN) + '\n') del row, rows myOutputFile.close()
... View more
07-11-2013
10:56 AM
|
0
|
0
|
1306
|
POST
|
For future reference, Census provides population center shapefiles for many levels of gegraphy: http://www.census.gov/geo/reference/centersofpop.html
... View more
06-26-2013
11:23 AM
|
1
|
3
|
1124
|
POST
|
I've been using Python for a short while and eagerly looking to find out if I could use Wingware IDE and be able to import ArcPy Site Pacage with Code Completion Support? Regards Yup. Wing IDE is top notch. I've used it for a couple of years now. Besides code completion, using the "Source Assistant" tab you can see all method/function documentation and syntax hints as you type.
... View more
04-22-2013
06:08 AM
|
0
|
0
|
312
|
POST
|
Have you opened up one of the .dat files in Wordpad? It may already be in ASCII format, in which case you could just change the .dat extension to .asc, insert the header information, and proceed that way. I've never seen the PRISM data distributed in .dat format. If you attach one of the files, I might be able to give better advice.
... View more
04-12-2013
06:21 AM
|
0
|
0
|
672
|
POST
|
Some additional observations and run times (HH:MM:SS). I ran the python script in 3 ways: 1. Using the Windows Command Prompt window. 00:03:43 2. From within PyScripter (no debugging, just a straight run using Run command). 1:21:33 3. Using the Windows Command Prompt Window, but I happended to have the python script open in PyScripter at the same time. 1:21:33 Note: Scenario 3 was the most interesting as it ran just as slow as scenario 2. The only difference being that the python file was open in PyScripter while trying to run from Windows Command Prompt. But if the python script was open in IDLE or Notepad while attempting to run from the Windows Command Prompt, it ran just as fast as in scenario 1 with in a few seconds. I also noticed under the Run > Python Engine menu, there are 4 options: Internal, Remote, Remote (Tk), and Remote (Wx). By default PyScripter has selected Remote. The following website explained the different options and limitations http://code.google.com/p/pyscripter/wiki/RemoteEngines. So I tried changing it to Internal from Remote. But that just made it worse, as the program never seemed to get through the first step and PyScripter went into Not Responding mode as I was forced to exit the application. Wow, that's an amazing difference. Much to my relief, I'm not seeing the same problem. I have a process I run hundreds of times that takes about 2 minutes and 30 seconds in IDLE and is maybe just a few seconds slower in Pyscripter (I've always used the Remote engine). I'm not even sure there is a difference, really. Maybe a reinstall of Pyscripter is in order? Seems like something is definitely off in your case.
... View more
03-29-2013
06:50 AM
|
0
|
0
|
1414
|
POST
|
pydap is what I have been using, but recently I have been trying to access data on a thredds server rather than an opendap server, and pydap was giving me issues on the thredds server that I never experienced with the opendap server, so that is when I decided to try netcdf4. The netcdf4 module worked on the thredds server, but only once, like I have explained, and then I keep getting this error each subsequent run. This code is being run out of a normal toolbox. I have never used a python toolbox, do you think that could be the problem? Well, the good news is that I can replicate your problem exactly. I'm using ArcGIS 10.0 sp5 on Windows 7 64. But Rich's tool seems to work fine on ArcGIS 10.1. My guess is that netCDF4 isn't playing nice with the standard toolbox. The only difference I can see between Rich's project and this error is the use of a Python Toolbox.
... View more
03-27-2013
03:55 PM
|
0
|
1
|
621
|
POST
|
Mostly speculation, but it might be because Pyscripter is running everything through a true debugger. IDLE is not.
... View more
03-27-2013
09:08 AM
|
1
|
0
|
1414
|
POST
|
Yes, very frustrating! I appreciate you taking a look though. So does the ScientificPython module not read opendap? I was thinking that may be a decent alternative if this issue can't be worked out, but I get an invalid argument error when I try and put in a url for the netcdf dataset. I think netCDF4 is the only package with built-in OPeNDAP support. I've used Pydap, but there are no Windows installers that I know of. You can install it using pip or easy_install. And it isn't as clean as the netCDF4 syntax: from pydap.client import open_url
daymetfile = open_url(r'http://daymet.ornl.gov/thredds/dodsC/allcf/2011/12484_2011/tmax.nc')
var_raw = daymetfile['tmax'].array[100,:,:] # this slices out data for the 100th day
# then I had to do some reshaping of the array and convert it to a raster using arcpy
# maybe there is a better way to do this?
I would say that netCDF4 is the preferred alternative. The error you're getting doesn't make much sense. Are you running the condensed code you posted earlier out of a Custom Toolbox or Python Toolbox?
... View more
03-26-2013
11:46 AM
|
0
|
0
|
621
|
POST
|
Something isn't making sense. The line that is throwing the error is doing nothing except checking to see if "elem" is an iterable. If you open up this file: "C:\Python27\ArcGIS10.1\lib\site-packages\netCDF4_utils.py", it looks like the import of numpy as np (on line 1) is only being executed successfully the first time you run the tool. Subsequent runs fail and only return a NoneType object. I have no idea why. Hopefully someone else can enlighten us both.
... View more
03-26-2013
05:41 AM
|
0
|
0
|
621
|
POST
|
Here is a condensed version of my code. You probably won't be able to access this data, but if you know of any other opendap data with a latitude variable, you could substitute that in the data line.
from netCDF4 import Dataset
data= 'http://cloud.insideidaho.org:8001/reacch/CMIP5/maca_huss_BNU-ESM_historical_1950_1959_WUSA.nc'
MyData=Dataset(data)
lt = MyData.variables['lat'][:]
arcpy.AddMessage(lt)
When I run as a script in an ArcGIS toolbox, it runs successfully the first time, and prints off all of the latitudes, the second time however, I get this error message: Traceback (most recent call last): File "C:\netcdf4 trouble\netcdf4problem.py", line 5, in <module> lt = MyData.variables['lat'][:] File "netCDF4.pyx", line 2631, in netCDF4.Variable.__getitem__ (netCDF4.c:32455) File "C:\Python27\ArcGIS10.1\lib\site-packages\netCDF4_utils.py", line 127, in _StartCountStride if np.iterable(elem): AttributeError: 'NoneType' object has no attribute 'iterable' Failed to execute (netcdf4problem). Nothing is jumping out at me. I can see that the climate variable has 3,650 time steps. Is your script designed to repeat itself 3,650 times in order to extract the climate variable and lat/lons for each time step?
... View more
03-25-2013
07:06 PM
|
0
|
0
|
621
|
POST
|
Thank you so much for the responses. I downloaded the python 2.7 version of ScientificPython, and for some reason I am not having success running the module within Arc. I keep getting an error of "IOError: netcdf: Invalid argument", but the same argument seems to be working outside of Arc. I also downloaded the mentioned netCDF4 module and I am getting the same error I was originally getting in the first post. My script runs perfect one time through, but then the next time through I am have problems. I first read in the netcdf file using: dataset= Dataset('nameofmynetcdf.nc') And then I try and read the latitudes using the command: lt = dataset.variables['lat'][:] This works perfectly the first time through, but then second time through I get an error for this line which states: AttributeError: 'NoneType' object has no attribute 'iterable' Does anyone know why this would be? I am reading this data via opendap if that makes any difference at all(?). I would really appreciate any help anyone has to offer. Thank you! It might best if you posted some or all of your code, and included the line number of the error. There are instruction at the top of the Python forum on how to post code here.
... View more
03-22-2013
12:45 PM
|
0
|
0
|
900
|
Title | Kudos | Posted |
---|---|---|
1 | 05-25-2012 05:22 AM | |
1 | 02-09-2018 01:19 PM | |
1 | 09-20-2011 11:59 AM | |
1 | 03-27-2013 09:08 AM | |
3 | 02-09-2018 06:34 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|