|
POST
|
I think it's because your input "file" does not represent anything other than the string of 'file'. Try the code below. Line 11 is giving the variable 'layer' to the complete path of the shapefile. import os
import arcpy
kmz_out = r"Z:/outPath"
for dirpath, dirnames, filenames in os.walk(r"Z:/inPath"):
for file in filenames:
if file.endswith('boundary.shp'):
layer = os.path.join(dirpath, file)
arcpy.LayerToKML_conversion(layer=layer,
out_kmz_file="kmz_out",
layer_output_scale="0", is_composite="NO_COMPOSITE",
boundary_box_extent="DEFAULT", image_size="1024", dpi_of_client="96",
ignore_zvalue="CLAMPED_TO_GROUND")
print "boundary has been made"
... View more
11-20-2017
08:30 AM
|
2
|
5
|
5431
|
|
POST
|
Holy cow! Dan, that worked! Thanks so much! All I did was move the script to the folder where the images are housed. You're the man.
... View more
11-17-2017
06:02 AM
|
1
|
0
|
3712
|
|
POST
|
I am trying to recreate/customize a tool (found here) which reads metadata from a JPG and creates a KML from it. The KML points to the relative path of the JPG and the image is displayed in the KML's pop-up window. I cannot get the image to show up and was hoping someone had an idea. The image below shows what the KML looks like in Google Earth. Here is the code that produces the KML. for directory, sub, files in os.walk(imageDir):
for f in files:
fullpath = os.path.join(directory, f)
relpath = os.path.relpath(fullpath) #I've tried passing both fullpath and relpath to Text below
data = get_exif_data(fullpath)
c = get_lat_lon(data)
coordinates = (c[1],c[0])
pnt = kml.newpoint(name=f, coords = [coordinates])
imgHeight = data['ImageLength']/4
imgWidth = data['ImageWidth']/4
project = 'Test'
date = data['DateTime']
device = 'Apple iPhone'
Text = '<img src="'+relpath+'" alt="path failed" width="{0}" height="{1}"'+\
'align="left"/>'.format(imgWidth, imgHeight)+\
'<br>Project Name: {0}'+\
'<br>Capture Date & Time: {1}<br>Device: {2}'.format(project, date, device)
pnt.style.iconstyle.icon.href ="http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png"
kml.save(outKML) Any ideas as to why this is happening. I'm 99% sure the path to the image is incorrect, but I'm out of ideas.
... View more
11-16-2017
07:22 AM
|
0
|
3
|
5725
|
|
POST
|
I think you're building your dictionary incorrectly. Right now, it's setting the key "FROM_NODE" to the variable new_node which is row[1]. Should it be something like this? node_values = {}
with arcpy.da.SearchCursor(fc, ['FROM_NODE','GRID_CODE']) as cursor:
for row in cursor:
old_node = row[0]
new_node= row[1]
node_values[old_node] = new_node If not, print your dictionary so we can see the contents.
... View more
11-15-2017
01:35 PM
|
0
|
8
|
3378
|
|
POST
|
I use the Python Excel module openpyxl. Please download this if it's not currently installed. The below code should work if the module is installed correctly. Please create an empty .xlsx file and set the path to the variable in line 26. import arcpy
import os
from openpyxl import Workbook
db = r'path_to_geodatabase_.gdb'
arcpy.env.workspace = db
#wb stuff
wb = Workbook()
ws = wb.active
ws['A1'] = 'FeatureClass'
ws['B1'] = 'Count'
count = 2
for ds in arcpy.ListDatasets():
for fc in sorted(arcpy.ListFeatureClasses('','',ds)):
fc_path = os.path.join(db, fc)
fc_count = str(arcpy.GetCount_management(fc_path))
print "{0} : {1} rows".format(fc, fc_count)
ws['A{0}'.format(count)] = fc
ws['B{0}'.format(count)] = fc_count
count += 1
output = 'path_to_output_Excel_.xlsx'
wb.save(output)
... View more
11-09-2017
06:28 AM
|
2
|
0
|
6240
|
|
POST
|
You can use Python for this. I am going to tag Python here for visibility. I've manipulated a code snippet found on StackExchange here to solve your problem. The below code should do the job. import arcpy
import os
db = r'path_to_database'
arcpy.env.workspace = db
for ds in arcpy.ListDatasets():
for fc in arcpy.ListFeatureClasses('','',ds):
fc_path = os.path.join(db, fc)
fc_count = arcpy.GetCount_management(fc_path)
print "{0} : {1} rows".format(fc, fc_count)
... View more
11-08-2017
06:31 AM
|
3
|
5
|
6241
|
|
POST
|
Have you tried using the Intersect geoprocessing tool?
... View more
11-06-2017
02:13 PM
|
0
|
0
|
703
|
|
POST
|
I'm not familiar with javascript API or how it plugs into your web service. However, the way I usually handle related records and searching between two tables is through a dictionary. signs = r'path_to_signs_fc'
relTable = r'path_to_related_table'
d = {row[0]:row[1] for row in arcpy.da.SearchCursor(signs, ['code','sign'])}
with arcpy.da.SearchCursor(relTable, ['code','signs']) as cursor:
for row in cursor:
if row[0] in d:
print d, row[0] #you can print, dump data into another container, etc...
del cursor Example of what the key, value pair dictionary looks like.
... View more
11-03-2017
07:04 AM
|
2
|
1
|
2348
|
|
POST
|
You should be able to find unique values with the arcpy.da module. import arcpy
inFeatures = r'path_to_feature_class'
outPath = r'path_to_output_database'
unique = set(row[0] for row in arcpy.da.SearchCursor(feautre, ['ID'])) #all unique values
arcpy.MakeFeautreLayer_management(inFeatures, 'lyr') #make layer to query
#loop over unique values, and select then dissolve
for u in unique:
arcpy.SelectLayerByAttributes_management('lyr', 'NEW_SELECTION', "ID = {0}".format(u))
outFC = os.path.join(outPath, u)
arcpy.Dissolve_management('lyr', outFC) EDIT: I'm sorry, I didn't originally understand the post. The updated code above may get you started.
... View more
11-02-2017
10:22 AM
|
2
|
0
|
1498
|
|
POST
|
If all Feature Classes use the same naming convention, the code below should work. It finds unique FCs bases on the [0] item in a string ('LINE' will get returned from 'LINE_pointErrors_1'). Then, it creates a folder for each FC group, then exports all FCs as .shp to that folder if the names match. import arcpy
import os
#database and workspace
db = r'path_to_database'
arcpy.env.workspace = db
#root directory to house output shapefiles
root = r'path_to_output_shp_folder'
#all Feature Classes in db
allFCs = arcpy.ListFeatureClasses()
#loop through FC and append each unique name to list
rootNames = []
for x in allFCs:
fc = x.split('_')[0] #assuming all FCs have an _ in the name
if fc not in rootNames:
rootNames.append(fc)
#loop through FC list and create directories
for r in rootNames:
output = os.path.join(root, r)
os.mkdir(output)
for i in allFCs: #if a FC is found in the being looped over dir (r), export
item = r.split('_')[0]
if item in i:
arcpy.FeatureClassToFeatureClass_conversion(i, output, i)
... View more
11-01-2017
11:48 AM
|
0
|
0
|
2193
|
|
POST
|
I would think there some attributes would include: Height Class Birthdate (date of installation) Condition Other attachments (on pole) Pole Owner I'm sure the telco would also want to know a price per attachment on pole. But, you wouldn't have to include that in the data model if it's a flat rate across all pole assets. I'm sure I'm missing a lot, but I like the question!
... View more
10-31-2017
12:47 PM
|
3
|
0
|
3776
|
|
POST
|
I've mentioned twice in this thread that I need a output table that is similar to the one created by the Symmetrical Difference tool.
... View more
10-30-2017
06:12 AM
|
0
|
2
|
1268
|
|
POST
|
I'm trying to accomplish what the Symmetrical Difference tool outputs, which is two tables merged to one. The left hand side of the table contains attributes from Table A and the right hand columns are Null or 0. Where there is no attributes to have for Table A, the right hand side of the table contains attributes from Table B while the left hand side of the table will be Null or 0. I hope that's not too confusing.
... View more
10-27-2017
09:10 AM
|
0
|
0
|
2470
|
|
POST
|
No, these two datasets are tables actually and do not have a spatial reference.
... View more
10-27-2017
08:08 AM
|
0
|
0
|
2470
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-28-2024 11:43 AM | |
| 1 | 09-12-2025 07:32 AM | |
| 1 | 10-26-2018 06:50 AM | |
| 1 | 10-26-2018 08:43 AM | |
| 1 | 02-25-2016 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
12-02-2025
01:10 PM
|