|
POST
|
Thanks Jake, that's always good advice on naming shapefiles. But I didn't name them. This is the hand I was dealt. Looks like I'm going to have to retrain these crews. I'm dealing with lots of tiny GPS files collected in the wrong projection with elaborate file names rather than attributes like date in the attribute tables. Two weeks ago I was dealing with removing spaces and - from the file names. http://forums.arcgis.com/threads/107870-AddLayer-and-.txt-files However, in this case the script will run correctly from the IDLE window, but I have to shut down the ArcCatalog and ArcMap to get an exclusive schema lock. Also, I changed the name of one shapefile to "dog.shp", and the script gave me the same workspace error in the ArcMap python window.
... View more
05-05-2014
09:03 AM
|
0
|
0
|
1102
|
|
POST
|
Last week I was rearranging the attribute tables of a bunch of shapefiles. It was working fine. It looked like this: # Import arcpy module import arcpy from arcpy import env env.workspace = "C:\\avdata\\FallChinookRedds\\2013\\Shapefiles\\" # Local variables: inshape = "MDhighway972211113.shp" fname = "\""+inshape+"\"" surdate = "\"11/01/2013\"" streamname = "\"Yakima River\"" specname = "\"Fall Chinook\"" # Process: Delete Field arcpy.DeleteField_management(inshape, "TYPE;Y_PROJ;X_PROJ;DISPLAY;SYMBOL;UNUSED1;DIST;PROX_INDEX;COLOR;DEPTH;TEMP;TIME;WPT_CLASS;SUB_CLASS;ATTRIB;LINK;STATE;COUNTRY;CITY;ADDRESS;FACILITY;CROSSROAD;UNUSED2;ETE;DTYPE;MODEL") #more steps ...... Most of the time I was editing python, changing the shapefile name, then dragging the code from IDLE to the ArcMap python window so I could keep the map open and not hit schema locks. This week I was doing the same thing to some 2012 shapefiles. I thought all I had to do was change the workspace env variable and it would work the same: # Import arcpy module import arcpy from arcpy import env env.workspace = "C:\\avdata\\FallChinookRedds\\" # Local variables: inshape = "2zillTOgra102312.shp" fname = "\""+inshape+"\"" surdate = "\"10/23/2012\"" streamname = "\"Yakima River\"" specname = "\"Fall Chinook\"" # Process: Delete Field arcpy.DeleteField_management(inshape, "TYPE;Y_PROJ;X_PROJ;DISPLAY;SYMBOL;UNUSED1;DIST;PROX_INDEX;COLOR;DEPTH;TEMP;TIME;WPT_CLASS;SUB_CLASS;ATTRIB;LINK;STATE;COUNTRY;CITY;ADDRESS;FACILITY;CROSSROAD;UNUSED2;ETE;DTYPE;MODEL") #more steps ..... but in the python window I get "ERROR 000732: Input Table: Dataset 2zillTOgra102312.shp does not exist or is not supported Failed to execute (DeleteField). " as soon as it hits that first DeleteField, as if the file name or path is wrong. However if I print env.workspace in the python window, I get the path I expect. And if I type listshapes = arcpy.ListFeatureClasses() , listshapes is filled with all the shapefiles in the workspace. Tried several other input shapefiles, but got the same type of error. The script for 2012 data works when I run it in python, but I have to shut down ArcMap and ArcCatalog to avoid hitting schema locks. What am I missing when I try to run this in the python window?
... View more
05-02-2014
02:49 PM
|
0
|
7
|
1939
|
|
POST
|
Finished! For the first step, txt files are read in, filenames are striped of blanks, -, and ".txt, then copied to a shapefile in a for loop
import arcpy, os
csvDir = r"c:\avdata\FallChinookRedds\2013\moretextfiles"
shpDir = r"c:\avdata\FallChinookRedds\2013\Shapefiles"
csvfiles = [os.path.join(csvDir, i) for i in os.listdir(csvDir) if i.endswith(".txt")]
for file in csvfiles:
arcpy.MakeXYEventLayer_management(file, "LONG", "LAT", "temp_outlayer",arcpy.SpatialReference(4326))
#remove spaces, -, and .txt in file name
file = file.replace(" ","")
file = file.replace("-","")
file = file.replace(".txt","")
print file
arcpy.CopyFeatures_management("temp_outlayer",os.path.join(shpDir,os.path.basename(file)))
arcpy.Delete_management("temp_outlayer")
This is what I wrote to add them to the closed map project from a Python console, not the ArcMap python window.
import arcpy, os
mxd = arcpy.mapping.MapDocument(r"c:\avdata\FallChinookRedds\2013\fallchinook2013.mxd")
print mxd
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
arcpy.env.workspace = r"c:\avdata\FallChinookRedds\2013\Shapefiles"
shpList = arcpy.ListFeatureClasses()
print shpList
for featureClass in shpList:
newLayer = arcpy.mapping.Layer(featureClass)
arcpy.mapping.AddLayer(df,newLayer)
del newLayer
mxd.saveACopy(r"c:\avdata\FallChinookRedds\2013\fallchinook2013-2.mxd")
del mxd
del df
Eventually, I'll run these shapefiles through some other scripts that add and populate some fields, get the date out of the file name and into a field, drop some other fields, and append into a geodatabase.
... View more
04-25-2014
11:49 AM
|
0
|
0
|
864
|
|
POST
|
Thanks, Matt, MakeXYEvent is going to work, I think. I just had to remember to import os at the start. Don't know yet how MakeXYEvent is going to handle the first line which is column headers. The script bombed when it hit the first txt file name that includes spaces, so it couldn't make a shapefile name with that character. A simple addition of file.replace(" ","") didn't fix this for me. I suppose I'll also need to strip off ".txt" as well. Added
file = file.replace(" ","")
file = file.replace("-","")
file = file.replace(".txt","")
print file
to the loop, and it ran through the first 9 files, created shapefiles, then hit a problem in the tenth file. Says field LONG and LAT do not exist. Looking into this file now. Update: That bad file was just a notepad file I made to capture some text. Deleted that and I'm on my way again. I thought some of these file names were going to be too long as well, but I got shapefiles. Aren't we limited to 8 characters for a shapefile name?
... View more
04-25-2014
09:04 AM
|
0
|
0
|
864
|
|
POST
|
I just got handed 30 comma delimited txt files from someone's old GPS unit and asked if I could put them on a map for their report due tomorrow. Sure, I could plow through these files one at a time, import the txt files to ArcMap, display XY data, convert to a feature class, and make the deadline. But wouldn't it be more fun and elegant to loop through all the txt files with a python script? Might not save any time, but I might learn something and I'd prefer to miss the deadline to teach these people that their lack of planning does not make my emergency. But I've already run into a problem. Although I can add these txt files with the ArcMap Add data button, I haven't been able to get AddLayer to add a txt file. Is it possible? Or is some other method used? What I tried in the python window was mxd = arcpy.mapping.MapDocument("CURRENT") addLayer = (r"C:\avdata\FallChinookRedds\2013\cent2don 10-14-13.txt") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] arcpy.mapping.AddLayer(df, addLayer) but just got a bunch of red runtime error stuff, nothing added to the map document. Don't know if I have a syntax error for the python window or AddLayer is not going to work with the txt file.
... View more
04-24-2014
03:41 PM
|
0
|
5
|
1303
|
|
POST
|
I got on a screen sharing session with an ESRI analyst. Showed him the error message and that Google Earth also wasn't working. We installed Fiddler so we could examine the internet traffic and the ArcGISServer connections started working, possibly because Fiddler acts as a proxy. We then tried to reset internet options, but couldn't because there was still an IE process running. We killed the IE process, reset internet options, and then were able to make ArcGISServer connections and Google Earth connections. However, a couple of days later, the PC owner complained that the PC was running slowly. When I looked, the PC was loaded up with malware again. I unplugged the network cable and ran some more malware fixes on it.
... View more
04-08-2014
08:17 AM
|
0
|
0
|
1917
|
|
POST
|
Right clicking the layer>Properties>source>resetting the data source in the map project is the obvious fix. That hasn't worked. That's why I went back to ArcCatalog to check the arcGISServer connections to arcGIS Online and tried to refresh or make them over. Each of these just gave the "Error: The parameter is incorrect" message. I turned off Spybot Resident and Symantic endpoint protection, and windows firewall, but still was unable to make the ArcGIS Server connections. The PC is showing under "Solve PC issues" solve a problem with Google Earth. Tried that but got ""could not be downloaded". In Google Earth I tired GE diagnostics, got a message that port 80 was blocked. If ArcGIS Server connections use port 80 also, this could be a clue. The PC will make a browser connection to the rest url. Last night, I manually opened port 80 for in and out. Didn't fix the Google Earth error or the ArcGISServer connection problem. I expected as much, because the earlier attempt at just temporarily bringing down the Windows firewall didn't fix anything. The owner of the PC wants to reformat the hard drive and reinstall windows and applications. I told him go for it. I'm ready to throw this PC out the window, and tell the front office there was an accident.
... View more
03-24-2014
03:51 PM
|
0
|
0
|
1917
|
|
POST
|
Oh, I see, I first need to add a field to hold the area calculation. Calculate Geometry doesn't create one for me.
... View more
03-24-2014
09:38 AM
|
0
|
0
|
2765
|
|
POST
|
What do I do when Calculate Geometry is grayed out, unavailable for a newly created shapefile, in an edit session, or out of an edit session? Win 7 Pro, 64 bit, ArcGIS Desktop 10.2.1
... View more
03-24-2014
09:26 AM
|
0
|
2
|
5602
|
|
POST
|
More info today. We temporarily brought down the PC's windows firewall, but it didn't help. User also reports that Google Earth doesn't work either. Do GE and AGS use the same port on a PC?
... View more
03-14-2014
12:08 PM
|
0
|
0
|
1917
|
|
POST
|
I have a user that reports that after running Spybot Search and Destroy, and correcting a few issues, (as recommended by our IT guy) now all his map projects that use services.arcgisonline.com are showing those map layers are missing or moved. He's running ArcGIS 10.x Win 7 pro 64. When I opened up his ArcCatalog, there were red x's on his AS connections. When I tried to make a new connection to services.arcgisonline/arcgis/services, AC came back with an error "Error: The parameter is incorrect". Not a very helpful message. There were some cases in the forum where this was corrected by changing the settings of Internet Explorer away from "work online" However, we are now running IE 11, and that is not an option to be found in IE settings. But it does point to some internet connection change on the system that was made by Spybot. Yesterday, I ran Spybot Search and Destroy on my WIN 7 64 PC as well, and my ArcServer connections to ArcDesktop 10.2.1 are still working.
... View more
03-13-2014
10:42 AM
|
0
|
4
|
2804
|
|
POST
|
Why am I having trouble getting your attachment today? All I get is "You don't have permission to access /attachments/ on this server." even though I'm logged in. Is it because the extension is .py?
... View more
02-25-2014
08:44 AM
|
0
|
0
|
850
|
|
POST
|
I'm planning to get a new server soon and move my ArcServer functions to the new hardware. Some of my power Arc Desktop users are wondering how this is going to effect all the map projects they have that use connections that are pointed at the old server. They are dreading going into all their map projects and finding a bunch of red ! in their TOCs and having to correct the source on each one. I'm wondering if there is a trick to making this transition more seamless. Is it possible to name the new server, AS instance, and databases exactly the same so that the Desktop users don't have to change a thing? Can I get away with it? Or are there any tricks to automate the change of source in the map projects of the client machines? Seems like I remember long ago, so long that it might have been written in Avenue, an Arc user script that was able to hack the project files, find each instance of a source string and replace it with the new path. Is there anything like that in user scripts for Desktop 10.x that could update source paths for any project in a directory or in a PC?
... View more
02-20-2014
01:51 PM
|
0
|
5
|
3546
|
|
POST
|
I just found out that it's a somewhat know bug in 10.2, caused be the existence of non-geotagged photos in your directory: http://forums.arcgis.com/threads/101704-Trouble-with-Geotagged-photos-to-points-tool
... View more
02-07-2014
12:40 PM
|
0
|
0
|
921
|
|
POST
|
I just found out it's a somewhat know bug in 10.2, perhaps caused by non-georeferenced photos in your directory. http://forums.arcgis.com/threads/92246-GeoTagged-Photos-To-Points-ERROR-999999-Error-executing-function.?highlight=geotagged In my case, upgrading to 10.2.1 fixed it. http://forums.arcgis.com/threads/101704-Trouble-with-Geotagged-photos-to-points-tool
... View more
02-07-2014
12:37 PM
|
0
|
0
|
2281
|
| 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
|