Hi Frank Perks
I am working with Georeferenced JPG, PNG and TIF Files and i need to create PRJ for individual files with its respective name. I have tried the first method. while running Python i am getting "IndexError: list index out of range". But i don't know C++. so i have not tried. can you give me the detail VBA code, that will be great for me.
Thanks
Senthilkumar
For the python error:
import os
import sys
import arcgisscripting
if __name__ == '__main__':
gp = arcgisscripting.create()
gp.workspace = r"PUT YOUR FOLDER HERE"
ds_list = gp.listrasters()
for ds in iter(lambda: ds_list.next(), None):
prj_str = gp.describe(ds).SpatialReference.exporttostring()
open(os.path.join(gp.workspace, '%s.prj' % os.path.splitext(ds)[0]), 'w').write(prj_str)
Okay lets say i have the files cat.jpg, mat.tif, hat.png, etc. and i want to make projection strings out of them. All of these files are in "C:\drseuss\rasters" (this path will be where your rasters are located, for this example i will use what i have written here)Before running the script we need to change this line: gp.workspace = r"PUT YOUR FOLDER HERE"To something that makes sense (always use forword slashes, it'll make stuff easier) gp.workspace = r"C:/drseuss/rasters"So it will look like this:
import os
import sys
import arcgisscripting
if __name__ == '__main__':
gp = arcgisscripting.create()
gp.workspace = r"C:/drseuss/rasters"
ds_list = gp.listrasters()
for ds in iter(lambda: ds_list.next(), None):
prj_str = gp.describe(ds).SpatialReference.exporttostring()
open(os.path.join(gp.workspace, '%s.prj' % os.path.splitext(ds)[0]), 'w').write(prj_str)
Now save the script, and run it! Now once its done: you will now have cat.prj, mat.prj, hat.prj files in C:/drseuss/rasters folder.I unfortunately don't know any sort of VBA. Try the modified script above. if that doesn't work them hopefully someone can convert the C++ code to VBA