Using Python in GIS: Text file to DBF

preview_player
Показать описание
First video in series in automating processes in GIS. This is not a Python tutorial per se, but rather an example of how to use Python in automating processes. In this example we are converting a text file into a DBF for further processing of Landsat scenes.

Twitter: @my_physical
Instagram: @MyPhysicalWorld

code used for this video: (I am not a programmer so this code might seem goofy to "real" programmers)

import os
import arcpy
from operator import itemgetter
# ------------------------------------Set path to the folder: (replace with your own filepath!):
#Print("Enter Directory:")
folder = r"D:\GISProgramming"
outFolder = r"D:\GISProgramming"
dbFolder = r"D:\GISData\Landsat"
# -------------------------------------------Set name of the file
# --------------------------------------Generate full filepath by combining the folder and filename
# ----------------------------------------------------Delete unneeded lines from MetaData file
with open(fileName) as old, open(newFile, 'w') as new:
# ---------------------------------------------------- Create clean Meta file and Database
of = open(op, "w")
arcpy.DeleteRows_management(OurTable)
with open(fp, "r") as infile:
Field = [] # -------------------------------------Creates Field List
Value = [] # -------------------------------------Creates Value List
Band = []
Type = []
Class = []
# -----------------------------------------------------Begin File Work
for line in infile:
if nline == "": # ---------------------------Test for End of File
print("Reached End of File")
break
else:
# print (nline)
fld = splitLine[0]
type = splitField[1]
cls = splitField[0]
bnd = splitField[3]
print(bnd)
# print(fld)
val = splitLine[1]
nval = "{:.7f}".format(float(val)) # -------Convert Scientific Notation to Decimal
# print(val)
# print(nval)
#print(splitLine)
row = [fld, bnd, nval, type, cls]
del editrows
Рекомендации по теме
Комментарии
Автор

Hello,

I have a problem with import arcpy I'm trying to install it as follows: pip install arcpy, could you help me?

Thanks

SamuelSilva-oidl
Автор

thanks for your effort
i have question
i do all steps but when i run i found this error
File "C:/Users/sara/PycharmProjects/pythonProject1/venv/diffucult.py", line 30, in <module>

File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 17401, in DeleteRows
raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Rows: Dataset E:\python test\InSatProcess.dbf does not exist or is not supported
Failed to execute (DeleteRows).
can you please help me to how to fix it
thanks

sarasameh
visit shbcf.ru