Hi Frank PerksThe script is working and its creating PRJ files for each files. but i am getting below error while opening the PRJ files in ARC Catalog.Error:Edit FailedFailed to create the Spatial reference system from the specified PRJ file. the input is not a workstation PRJ files.ThanksSenthilkumar
import os import sys import arcgisscripting def fix_proj_str(proj): """ Correct a projection strings exporttostring uses single quotes instead of double! BUG! """ return proj.replace("'", '"') if __name__ == '__main__': gp = arcgisscripting.create() gp.workspace = r"CHANGE THIS TO YOUR PATH" ds_list = gp.listrasters() for ds in iter(lambda: ds_list.next(), None): prj_str = fix_proj_str(gp.describe(ds).SpatialReference.exporttostring()) open(os.path.join(gp.workspace, '%s.prj' % os.path.splitext(ds)[0]), 'w').write(prj_str)
Hi Frank PerksI 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.ThanksSenthilkumar
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)
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)
Hi Frank PerksI have tried you method, but Still I am not getting the PRJ Files. can you give me the details code for that.ThanksSenthilkumar
""" Takes a workspace and creates prj files for rasters sys.argv[1] ds dir -Frank Perks """ import os import sys import arcgisscripting if __name__ == '__main__': gp = arcgisscripting.create() gp.workspace = sys.argv[1] 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' % ds), 'w').write(prj_str)
HRESULT ExportPrjToFile(__in const IRasterPtr& ipSrcRaster, __in const ATL::CComBSTR& outputPath) { HRESULT hr; IRasterPropsPtr ipRastProps = ipSrcRaster; ISpatialReferencePtr ipSrcSp; hr = pRastProps->get_SpatialReference(&ipSrcSp); if(FAILED(hr)) { std::cerr << "[ERROR]: Cannot extract Spatial Reference from Raster" << std::endl; return hr; } ISpatialReferenceFactoryPtr ipSpFact(CLSID_SpatialReferenceEnvironment); // Get Spatial Ref store to file return ipSpFact->ExportESRISpatialReferenceToPrjFile(outputPath, ipSrcSp); }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.