POST
|
Beautiful Jake, That seems to have worked. I'm guessing that os.path.basename(raster) stripped the path that was appended in the rasters =[] list? Anyways I think this should do. Thank you for your help. I'll just action this as correct as it did complete what I set out for.
... View more
11-28-2018
01:00 PM
|
0
|
1
|
454
|
POST
|
I am on ArcGIS 10.4. But it is indeed useful to know that about ArcPro for future reference.
... View more
11-28-2018
11:13 AM
|
0
|
3
|
454
|
POST
|
Yes I have already looked at that code sample and that is actually where I got the [:-4]. The script did work for individual folders, so it is possible that the way I have my walk setup or the raster list appended might be causing issues. But I do need this to work with a walk as it is the best way of parsing through a folder tree while ignoring images in geodatabases and in mosaics. The statement Jake provided as shown in the responses below did give an unexpected result.
... View more
11-28-2018
09:00 AM
|
0
|
0
|
973
|
POST
|
Tried simply using print (os.path.join(outPoly)) Without outFile, it returned the same thing as if I had (outFile, outPoly) D:\Folder\Test\Imagery\Applanix\Cambridge\21671694.shp
... View more
11-28-2018
08:53 AM
|
0
|
0
|
973
|
POST
|
So adding the command line as so: outPoly = raster[:-4]+"shp" print (os.path.join(outFile, outPoly)) arcpy.RasterDomain_3d(.....) returns paths for each file as follows: D:\Folder\Test\Imagery\Applanix\Cambridge\21671694.shp I'm guessing this means it is still reading the outFile as the workspace?
... View more
11-28-2018
07:40 AM
|
0
|
1
|
973
|
POST
|
Hey Dan, There is a large variety of types, .TIF is the most common but we also have .TIL .IMD .NTF .JPG, etc. I did this because I started trying this out with model builder, but the model would end up saving the file as a "Raster.tif.shp" which gave errors with following tools. When I switched over to a script instead of a model I kept that code to slice off the .tif or which ever extension to make sure I get a .shp and not a .tif.shp shapefile like I use to get in the model builder. And there is no error message the script runs as it should and it outputs a shapefile with the same name as the raster with the footprint. It just does not save it where I want it to be saved.
... View more
11-28-2018
07:19 AM
|
0
|
2
|
973
|
POST
|
Hey Jake, Gave that a shot, it still exported the shapefiles to the workspace, there are no shapefiles in the outfile folder. The script did still run without any errors though.
... View more
11-28-2018
07:10 AM
|
0
|
3
|
973
|
POST
|
I have a folder tree with many other folders in it containing many images. I have managed to make a script that will parse through the entire folder and find every image in it. It then uses raster domain to create a polygon shapefile of every footprint for each image. The issue I am having is I need to have those footprints exported to a single folder named "index". The current script always exports the footprints to the same folder the image is located in. How can I change my script to export the raster domain footprints to the "index" folder instead of them being exported to the folder containing the imagery? Here is my script: import arcpy import os workspace = r”D:\Folder\Test” outFile = r”D:\Folder\Index” rasters = [] arcpy.CheckOutExtension(“3D”) print ‘Processing’ for dirpath, dirnames, filenames, in arcpy.da.Walk(workspace, topdown=True, datatype=”RasterDataset”): for filename in filenames: rasters.append(os.path.join(dirpath, filename)) for raster in rasters: outGeom = “POLYGON” outPoly = raster[:-4]+”.shp” arcpy.RasterDomain_3d(raster, outPoly, outGeom) print rasters print ‘Completed’ I'm pretty sure the answer lies with changing the "outPoly" parameter but anything I have tried resulted in an error. Any help would be much appreciated. Thank you for your time.
... View more
11-27-2018
02:12 PM
|
0
|
14
|
1666
|
Online Status |
Offline
|
Date Last Visited |
07-05-2023
06:15 PM
|