POST
|
Hi All, I'm trying to figure out how I can calculate the time it would take to travel from Many different points to a single point and then create a "heatmap" based on the time it would take to get from these points to the central location. If someone can point me to a tutorial or reference on how to do this I would greatly appreciate it.
... View more
10-28-2016
07:52 AM
|
0
|
1
|
615
|
POST
|
I believe I have the issue. I'm using the lyr.name to name the files that are output. The issue with this is that the layer names have spaces in them. I believe if I format those it will fix the issue. Kind of disappointed in myself for overlooking this...
... View more
07-13-2016
05:44 AM
|
0
|
0
|
615
|
POST
|
I'll add print statements for all of the paths and I'll reformat so that the slash is added between the file name and the path. I'll update when I have results. Thanks for your help, gentlemen!
... View more
07-13-2016
05:17 AM
|
0
|
0
|
615
|
POST
|
Ah good point. I'll edit the original post as such. thanks.
... View more
07-12-2016
11:50 AM
|
0
|
0
|
615
|
POST
|
Hello everyone, I've got a question on arcpy. I have a script that is going to select some features out of a few hundred feature classes and export them based off of proximity to my desired location. My issue is I keep getting the 000210 which, to my understanding, means i do not have access to the database I'm trying to write to. I've included my script and error message below. If anyone has any ideas on what might be causing this, i would greatly appreciate the guidance. '''
Created by SGT Russel Klueg
11 JULY 16
About: This script is meant to increase the response time of data creation
by allowing for the earthquake to be put in and outputting KMLs of all critical
infrastructure within a set distance of the location.
'''
import os, time, arcpy, csv
from arcpy import env
#Allows data to be overwritten
env.overwriteOutput = True
path = r'C:\Users\JOC-001\Desktop\Python Scripts\Earthquake\Earthquake Infrastructure.mxd'
#sets the path listed as the Map Document
mxd = arcpy.mapping.MapDocument(path)
#declares the Dataframe
df = "HSIP"
outPath = 'C:/Users/JOC-001/Documents/ArcGIS/Scratch.gdb/'
env.workspace = outPath
sr = arcpy.SpatialReference("WGS 1984")
#Takes the current time and creates a folder from it in YYYYMMDD HHMM format
current = time.strftime('%Y%m%d %H%M')
os.mkdir(current)
earthquake = 'C:/Users/JOC-001/Desktop/Python Scripts/Earthquake/'
folder = earthquake + current + '/'
print("The output folder for this entire process is below:\n" + folder)
#the next few lines take a verified user input to use as the Lat and Long
lat = float(raw_input("Please enter the Latitude of the event." + \
"\nNumber should range between between 36.5 and 42.5\n"))
while lat < 36.5 or lat > 42.5:
lat = float(raw_input("Please enter a valid Latitude between 36.5 and 42.5\n"))
long = float(raw_input("Please enter the Longitude of the event." + \
"\nNumber should range between between -87 and -92\n"))
while long < -92 or long > -87:
long = float(raw_input("Please enter a valid Longitude between -87 and -92\n"))
finalCoords = folder + 'coords.csv'
#Creates a csv file and moves it into the appropriate folder
with open('coords.csv', 'wb') as coords:
writer = csv.writer(coords, delimiter=',')
data = [['Lat', 'Long'],[lat, long]]
writer.writerows(data)
os.rename(earthquake+'coords.csv', finalCoords)
#Creatst the layer, converts to .shp and buffers it at 50 miles.
eventPoint = folder + 'event.lyr'
arcpy.MakeXYEventLayer_management(finalCoords, 'Long', 'Lat', 'Event', sr)
arcpy.SaveToLayerFile_management('Event', eventPoint)
arcpy.FeatureClassToFeatureClass_conversion(eventPoint, outPath, 'finalPoint')
arcpy.Buffer_analysis(outPath + 'finalPoint', 'pointBuffer', '50 Miles')
bufferFile = outPath + 'pointBuffer'
#Iterates through every single layer in the MXD and selects data and exports it.
for lyr in arcpy.mapping.ListLayers(mxd):
if not lyr.isGroupLayer:
name = lyr.name
arcpy.SelectLayerByLocation_management(lyr, 'INTERSECT', bufferFile)
arcpy.CopyFeatures_management(lyr, name)
os.system('pause') Traceback (most recent call last): File "C:\Users\JOC-001\Desktop\Python Scripts\Earthquake\Earthquake.py", line 67, in <module> arcpy.CopyFeatures_management(lyr, name) File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 2429, in CopyFeatures raise e ExecuteError: ERROR 000210: Cannot create output C:/Users/JOC-001/Documents/ArcGIS/Scratch.gdb\Animal Aquaculture Facilities Failed to execute (CopyFeatures).
... View more
07-12-2016
10:25 AM
|
0
|
6
|
2421
|
POST
|
Xander Bakker, The way my code is written, that is part of the reason I chose to use str(lyr) i'm not exactly a strong scripter and using the group layer name to create unique files was easiest for me . I'm self taught and only over the last couple months. I've still got a lot to learn. Especially in arcpy. I really appreciate your advice:D
... View more
06-27-2015
12:27 PM
|
0
|
0
|
1877
|
POST
|
Oh sweet that's pretty nice and super easy too. I was lost at the bracket. I caught on that you were using ranges but was still kind of confused. This is pretty sweet! I think i'll update my code to use this! Thanks:D
... View more
06-27-2015
08:40 AM
|
0
|
3
|
1878
|
POST
|
I'm still fairly new to python and I'm not sure how that method works. I would say i know just enough to casue myself a lot of problems! Would you mind giving a quick explanation? If not i'll dive into the python help pages! I did get my code working though. I'll post it below if you want to see it. import arcpy
import glob
import os
#glob is used to use the wildcard option for anything under this file to allow for removal of all files
files = glob.glob(r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015\*')
for f in files:
os.remove(f)
#Defines 'mxd' as the Map Document to be referenced
mxd = arcpy.mapping.MapDocument(r'C:\Users\JOC-001\Documents\GIS\HSIP\Infrastructure\HSIP_Gold_2015_Infrastructure.mxd')
#Defines the layers to be used as everything under Layers dataframe in the table of contents for the mxd
layers = arcpy.mapping.ListLayers(mxd)
#Iterates over each layer in the list of 'layers'
for lyr in layers:
#checks to see if any file is a Group layer rather than a single layer
if lyr.isGroupLayer:
pass
#Once layers pass the group layer check this initiates the geoprocessing.
else:
lyr2 = ''.join(ch for ch in str(lyr) if ch.isalnum())
print lyr2
arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")
arcpy.FeatureClassToFeatureClass_conversion(lyr, r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015', lyr2)
... View more
06-27-2015
05:57 AM
|
0
|
5
|
1878
|
POST
|
I actually found a pretty nice method to handle converting a string to Alpha Numeric characters ''.join(ch for ch in str(lyr) if ch.isalnum()) as for the copy features, thats a much better idea than FC2FC.
... View more
06-24-2015
10:02 AM
|
1
|
9
|
1878
|
POST
|
Hi all, I'm back at it again. I've written a script to Iterate through an MXD and export all features within 50 miles of my state to a feature class. There are over 550 FCs to process and it keeps failing due to invalid characters. Does arcpy offer a way to parse out invalid characters when naming a conversion output? Below is the code i'm referencing import arcpy
import glob
import os
files = glob.glob(r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015\*')
for f in files:
os.remove(f)
mxd = arcpy.mapping.MapDocument(r'C:\Users\JOC-001\Documents\GIS\HSIP\Infrastructure\HSIP_Gold_2015_Infrastructure.mxd')
layers = arcpy.mapping.ListLayers(mxd)
for lyr in layers:
if lyr.isGroupLayer:
pass
else:
print lyr
arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")
arcpy.FeatureClassToFeatureClass_conversion(lyr, r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015', str(lyr.name))
... View more
06-24-2015
08:32 AM
|
0
|
12
|
5846
|
POST
|
You and Wes Miller were on the same track. I knew that was the issue after adding the print statement but I didnt know that arcpy had an inherent option for dealing with it! You guys are great! Thank you so much!
... View more
06-24-2015
07:53 AM
|
1
|
0
|
654
|
POST
|
I want to thank everyone who helped me! I really appreciate all of you taking the time to help me solve this!!
... View more
06-24-2015
07:52 AM
|
1
|
0
|
654
|
POST
|
i had to tweak it just a little for the output to work on mine... but you sir are a wizard
... View more
06-24-2015
07:51 AM
|
0
|
0
|
654
|
POST
|
Agriculture\Animal Aquaculture Facilities Runtime error Traceback (most recent call last): File "<string>", line 10, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 1675, in FeatureClassToFeatureClass raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (FeatureClassToFeatureClass). This is what printing before the operation gives me. I think it has to do with how the layer A) has the group name attached. I'll need to parse that out. B) has spaces in the name, I'll need to parse that out as well i think.
... View more
06-24-2015
07:29 AM
|
0
|
4
|
654
|
POST
|
So it's close I think. I had to fix the FC2FC a bit more but now i'm getting this error that provides no help at all 😕 Runtime error Traceback (most recent call last): File "<string>", line 9, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 1675, in FeatureClassToFeatureClass raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (FeatureClassToFeatureClass). import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\Users\JOC-001\Documents\GIS\HSIP\Infrastructure\HSIP_Gold_2015_Infrastructure2.mxd')
layers = arcpy.mapping.ListLayers(mxd)
for lyr in layers:
if lyr.isFeatureLayer:
arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")
arcpy.FeatureClassToFeatureClass_conversion(lyr, r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015', str(lyr))
... View more
06-24-2015
07:26 AM
|
0
|
0
|
999
|
Title | Kudos | Posted |
---|---|---|
1 | 06-24-2015 07:52 AM | |
1 | 06-24-2015 10:02 AM | |
1 | 06-24-2015 07:53 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|