|
POST
|
I need a little hint because I see now I don't understand enough about file input and output in Python. I have some ascii lidar files that need to have the first column in each line removed to get them ready for the XYZI format of the ASCII 3D To Feature Class tool. I wanted to make a list of all the files in a folder with the suffix .gnd and output the modified data to files with the same name but a txt suffix so the original ascii files were not modified. What I got started with was: env.workspace = "G:/elevation/lidar2010/points/asc_grounds" fileSuffix = ".gnd" txtList = arcpy.ListFiles("*" + fileSuffix) for file in txtList: for line in open("my file"): parts = line.split(" ") print " ".join(parts[1:4]) Then I was stuck. I guess I need a new line inside the first loop to write the file to a new file name with a .txt suffix, and I haven't even figured out how to get the file name stripped of the suffix. What I used to do was I had an XP machine with Unix services for Windows installed that somehow let me use the Linux cut command inside a dos bat file: for %%f in (*.gnd) do call :sub %%f %%~nf GOTO:EOF :sub cut -d" " -f2-4 %1 > %2.txt The DOS %~ can give you a lot of useful file name manipulations. I installed Unix Services for Windows on a new Win 7 64 machine, and I don't understand why, but cut is not available to bat files on the new machine, although I can start a Unix C or K shell where cut is available but the %~n trick is not.
... View more
10-24-2012
10:35 AM
|
0
|
5
|
2436
|
|
POST
|
http://arcscripts.esri.com/details.asp?dbid=14856[/url] ), a free set of tools that will read the embedded GPS data in the EXIF, to create a geolocated photo layer on-the-fly or create a photo feature class with option to treat the photos as managed or unmanaged rasters.ArcPad. I've been trying that ArcScript but I can't get it to run with Desktop 10.1. When I try to run the exe, it asks for ESRI .NET support. I verified that the machine has .NET Framework 2.0 installed. When I try to add .NET support to ArcDesktop 10.1 with add remove programs, I don't see the option for .NET anymore.
... View more
10-01-2012
09:56 AM
|
0
|
0
|
942
|
|
POST
|
I found 9.3.1 on an older laptop that I use when traveling to my other office. I had a ridiculous amount of trouble getting it logged into this network so it could get a license over this office's network. However, I'm getting the same error messages with 9.3.1 ArcMap Distributed Geodatabase toolbar as with 10.0.
... View more
07-26-2012
10:18 AM
|
0
|
0
|
532
|
|
POST
|
I've been stumbling along towards distributive databases to see if it will serve as a way for a cooperative interagengy data system for my region. For my testing I copied a feature class and several auxillary tables into SDE, added global ids and published a map service and geodata service of the feature class. My server is using ArcGIS 9.3.1 and ArcServer 9.3.1, SDE with SQL server. Well, the global ids are in there, it's registered as versioned, the spatial reference system is high res, but I still haven't been to do any of the distributed database stuff, like extraction or create a local copy for editing or create any level of replica. In ArcMap 10.0 on a client PC, if I try right clicking the goedatabase service in a map TOC, and try "Edit Features>Create Local copy for editing" I get "Create Replica failed The requested capabiltiy is not supported." If I try the Extract Data Wizard from the distributed geodatabase toolbar to a client PC personal geodatabase, I get "Data extraction failed Generic server error message. When I try the toolbar's Create Replica Check-out, I get "Create Replica failed. The requested capabiltiy is not supported." When I try the toolbar's Create Replica Wizard, one way, parent to child to a client PC file geodatabase, I get "Create Replica failed. The requested capabiltiy is not supported." When I try the toolbar's Create Replica Wizard on the SDE feature class, one way, parent to child to a client PC file geodatabase, I get "Create Replica failed. Network I/O error [spawning.sde.GDB_ObjectClasses} Network I/O error." Update: I went back to my server and recreated the map service and the geodata service to make sure the box "versioned with the option to more edits to base" was not checked. But I still get the same errors on my client PC when I try to edit or create replicas. Howver, I noticed a moderate level warning from ArcServer Manager 9.3.1 when I published the services that it "contains data from SDE that is not a direct connection". Is this a requirement for distributed databases? Update: I went back to the server and made a direct SDE connection to the geodatabase, created a new map project with the Feature Class added from the direct connection, and published a new map service and geodata service. Still, the data replication stuff didn't work for me.
... View more
07-25-2012
12:36 PM
|
0
|
2
|
770
|
|
POST
|
Thanks, Ken, that's working for me. But the other thing I was trying to do to make the same label was to create a new item and use the field calculator and python to calculate the shorter date string. I thought I knew more about python but I couldn't get the syntax right. It seems like you'd use strftime, but maybe it doesn't work because the source item is already a date, not a string.
... View more
06-13-2012
05:19 PM
|
0
|
0
|
1699
|
|
POST
|
I thought I could reformat a date variable to drop the year for a map label but all I can get from the label expression advanced box is "The expression contains an error. Modify the expression and try again." Tried FormatDateTime([StartDate], 1) and Function ShortDate ( [StartDate] ) ShortDate = FormatDateTime([StartDate],1) End Function where StartDate is a date item in my table formated mm/dd/yyyy For the second FormatDateTime argument, I've tired 1 and 0.
... View more
06-12-2012
11:04 AM
|
0
|
2
|
5334
|
|
POST
|
If you want to discuss this further, just post your e-mail. 🙂 I'm interested. huffmanp@ykfp.org. I have been trying to keep an ftp site in sync with a linux website directory and I've been going about this very inefficiently, partly because few feature requests keep being added on. I wrote a little perl script a few years ago to give users a form to upload files to a directory on the web site. Recently I was asked if I could write a version of the script to allow uploads for a new project to a new directory, and also push these files out to an ftp account on the hosting company, so the users of this data could access the ftp directory without needing the username, password of the website and have these users pawing through all the directories on the web site to find the one they are supposed to be accessing. The most logical thing for me to do would be to modify the perl script to push a copy of any file uploaded to the ftp site also. But I looked at the perl script and though "Cripes, I've forgotten everything I ever knew about perl." I looked at Uber-Uploader since it's written in php which I can manage a bit better and has a perl component so the upload file size can be larger than with php without fiddling with php.ini settings. But I couldn't get Uber-Uploader to run on my host. Then I started looking at python ways to do it since I need to get better with python. I got python to work for me thusly: import ftplib
import os
import sys
import traceback
print "Logging in..."
ftp = ftplib.FTP()
ftp.connect('ftphostname')
print ftp.getwelcome()
try:
try:
ftp.login('username', 'password')
ftp.cwd('target directory')
# move to the desired upload directory
print "Currently in:", ftp.pwd()
print "Uploading...",
fullname = '../sourcedirectoy/filename'
name = os.path.split(fullname)[1]
f = open(fullname, "rb")
ftp.storbinary('STOR ' + name, f)
f.close()
print "OK"
print "Files:"
print ftp.retrlines('LIST')
finally:
print "Quitting..."
ftp.quit()
except:
traceback.print_exc() But now I'll have to see if I can make it work on a whole directory. If I were clever, I'd run this python script every few hours as a cron job (in windows, a "scheduled task"), and test the source directory for any file newer than last time the script ran in a cron. If I were really clever, I'd just add the ftp push to my original perl script.
... View more
02-27-2012
02:28 PM
|
0
|
0
|
8852
|
|
POST
|
What's this all about? I created a couple versions of a pour point layer, one a point shapefile, another a point FC in a file geodatabase, but when I try to snap either version of the point to an accumulation raster in the python window I get: >>> snappourfill = SnapPourPoint("point2","accumfill",20)
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000861: Pour point field: is not valid. Edit: But snappourfill = SnapPourPoint("point2","accumfill",20,"Id") does work. So even though the help system for Arc Desktop 10 says the third parameter, the pour_point_field, is optional, apparently it is required. No reference to Error 000861 found searching Support.
... View more
12-13-2011
11:27 AM
|
0
|
0
|
844
|
|
POST
|
What's this all about? I created a couple versions of a pour point layer, one a point shapefile, another a point FC in a file geodatabase, but when I try to snap either version of the point to an accumulation raster in the python window I get: >>> snappourfill = SnapPourPoint("point2","accumfill",20)
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000861: Pour point field: is not valid.
... View more
12-13-2011
11:26 AM
|
0
|
0
|
1089
|
|
POST
|
Thanks Richard. I didn't figure out a way to easily change a group of vertexes, but I figured out how most people update DEMs. I've been creating a new point or line feature class with a item called "value", then editing in new elevation values into this "value" item, then running this feature class through the "Feature to Raster" tool using the "value" item as the field input, then slipping the new cell values into the old DEM with a Con statement in Map Algebra. In the python window the syntax is like: demfix = Con(IsNull(Raster("newvalues")),"olddem","newvalues")
... View more
11-15-2011
09:17 AM
|
0
|
0
|
778
|
|
POST
|
I tried to run a watershed delimitation on a small piece of 10m DEM in Central Washington State. I was getting some strange results and when I examined the accumulation grid, I found that a seam in the DEM was causing all the flow from an adjacent drainage to get captured by my drainage. I set about trying to correct this DEM. I figured I'd just go Raster to Multipoint, create a point FC with Z values to act like little dams and channels in the surface, create a new terrain from the multipoints and the new point feature class, then terrain to raster, and rerun the watershed. But editing the point feature class has become my problem. When I created the points layer, I created it to contain Z-values, and I added an attribute called VALUES, and when editing, I stuck the desired corrected elevation into the VALUES attribute. The only way I could figure out to get the corrected elevation into the Z-values while editing was by editing the vertices under Sketch Properties, and I could only do one at a time. I thought I would just "Populate Zs from attributes". But after I got this far, it seems that "Populate Zs from attributes" is only available from Production Z Management and Production Editing, but I think Production Editing is only available in the Nautical or Aeronautical extensions which I don't have. Searching support I found VBA solutions to updating Z values from attributes, but that seems to be only applicable to 9.x. I'm trying to figure out how to do this in 10.0, SP3.
... View more
11-07-2011
02:48 PM
|
0
|
2
|
5275
|
|
POST
|
Now I see in the docs for con that there are two different syntax constructions for con, one with a where clause and one without, but the one without a where clause requires the Raster function. And this is different than in other map algebra environments. I tried the line in python without Raster, and I got ArcMap to crash again. if I set the input to a variable name I don't need to enclose it in quotes again: >>> accum = "accum" >>> accum9M = Con(Raster(accum) > 9000000, 1, 0) This ran to completion, creating a new accumulation raster, with values set to 1 for true and 0 for false. Then I tried it without the false condition: accum10M = Con(Raster(accum) > 10000000, 1) This ran, creating a raster with only the data that tested true, the rest nodata. It was also confusing to me that even though I had set the env.workspace, these new rasters were written to some default directory until I added a save line like accum9M.save("c:/avdata/topsim/utm/accumtest/accum9M")
... View more
11-02-2011
09:59 AM
|
0
|
0
|
608
|
|
POST
|
Is there a difference? Both cellSize and Cellsize are in the env. autocomplete. But after setting cellSize = 10, Cellsize also was found to be set to 10. But when I tried to run "accum9M = Con("accum">9000000,1)" again, python tried, then I got back to:
... View more
11-01-2011
02:48 PM
|
0
|
0
|
608
|
|
POST
|
I wanted to generate a few flow accumulation grids for alternative pour point inputs. The docs more map algebra made it seem like it would be simple to do this in the python window. But I can't get my env set up correctly. Why isn't easy like: http://forums.arcgis.com/threads/32283-set-extent I've been trying stuff like: import arcpy from arcpy import env from arcpy.sa import * env.workspace = "c:/avdata/topsim/utm/accumtest" env.cellSize = 10 # env.extent = "c:/avdata/topsim/utm/accumtest/accum" mxd = arcpy.mapping.MapDocument("CURRENT") env.cellSize = 10 df = arcpy.mapping.ListDataFrames(mxd,mxd.activeView) env.extent = df[0].extent accum9M = Con("accum">9000000,1) but when the line setting the extent to an existing file env.extent = "c:/avdata/topsim/utm/accumtest/accum" was followed by the map algebra line, ArcMap 10, sp3, crashed hard to the "ArcMap has encountered a serious problem" reporting window. So I tried to set it to the extent of the current dataframe, lines 7,9,10. But only get a "No CellSize and Extent set" run time error. But when I try to print out the extent, it looks valid, and the cellSize seems to be set to MAXOF.
... View more
11-01-2011
01:05 PM
|
0
|
4
|
2523
|
|
POST
|
Thanks - Nelson. When I typed MOD into MS Access Help Search I got pages of unrelated crap. [intContour] MOD 1000 = 0 worked for me as well. Didn't matter in I used "Contour", the double version of my item or "intContour" the short integer.
... View more
10-27-2011
01:00 PM
|
0
|
0
|
3548
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-28-2018 04:57 PM | |
| 3 | 09-20-2017 02:37 PM | |
| 1 | 09-20-2017 02:21 PM | |
| 1 | 03-09-2018 03:25 PM | |
| 1 | 03-12-2015 02:06 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|