|
POST
|
In numpy what's wrong about that? How to define the field to write in? And how to write XMIN, XMAX, YMIN, YMAX in one array and then in the right fields? npa = numpy.array(Xmin) arcpy.da.NumPyArrayToTable(npa, fc, fld_xmin) TypeError: narray.fields require
... View more
01-29-2015
05:50 AM
|
0
|
3
|
6994
|
|
POST
|
cur.updateRow(row) doesn't work as well ? # -*- coding: cp1252 -*-
# Export zu rastercatalog.dbf
# Autor Xander Bakker, Dan Patterson - vermurkst JB
import arcpy, os, math
from arcpy import env
Fgdb = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
arcpy.env.workspace = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
# Ausgabepfad = (r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster").strip()
Ausgabepfad = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster"
ext = ".jpg"
## arcpy.AddField_management(Ausgabepfad + "\Orthos_Nummern.shp", "IMAGE", "TEXT", 100) # , "", "", "refcode", "NULLABLE", "REQUIRED")
ext = ".jpg"
fc = os.path.join(Ausgabepfad, "Orthos_Nummern.shp")
fld_oid = "OBJECT_ID" # or: arcpy.Describe(fc).OIDFieldName
fld_out = "IMAGE" # should exist in shapefile
fld_xmin = "XMIN"
arcpy.AddField_management(fc, "XMIN", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "XMAX", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "YMIN", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "YMAX", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
def print_attributes(obj):
for attr in arr.__dict__:
print attr, getattr(arr, attr)
input_shp = fc
arr = arcpy.Array()
with arcpy.da.UpdateCursor(input_shp,['FID','SHAPE@']) as cur:
extents = []
for row in cur:
ext = row[1].extent
p0 = ext.lowerLeft; p1 = ext.upperRight
print('Extent of shape... {}: '.format(row[0]))
print(' X min/max {}, {}'.format(ext.XMin,ext.XMax))
Xmin = round((ext.XMin), 0)
print (Xmin)
print_attributes(row)
row.setValue(fld_xmin, Xmin)
print ( ' X min, {}'.format(ext.XMin))
cur.updateRow(row)
print(' Y min/max {}, {}'.format(ext.YMin,ext.YMax))
arr.add(p0)
arr.add(p1)
mp = arcpy.Multipoint(arr)
print('Extent of all {}'.format(mp.extent))
##rows = arcpy.UpdateCursor(fc)
##for row in rows:
## fld_oid1 = int(row.getValue(fld_oid))
## int_fld_oid1 = str(fld_oid1)
## # path = os.path.join(Ausgabepfad, "{0}{1}".format(row.getValue(fld_oid), ext))
## path = os.path.join(Ausgabepfad, int_fld_oid1 + ext)
## print (path)
## path1 = str("" + path + "")
## row.setValue(fld_out, path)
## rows.updateRow(row) Error: Extent of shape... 0: X min/max 3510999.9998, 3511999.9998 3511000.0 _arc_object <geoprocessing array object object at 0x02B88368> Traceback (most recent call last): File "R:\Karto\zGIS\Python\exportrastercatalog.py", line 43, in <module> row.setValue(fld_xmin, Xmin) AttributeError: 'list' object has no attribute 'setValue' Thought I wold get some information through def print attributes?
... View more
01-29-2015
04:04 AM
|
0
|
5
|
6994
|
|
POST
|
Error message: File "R:\Karto\zGIS\Python\exportrastercatalog.py", line 49, in <module> row.setValue(fld_xmin, Xmin) AttributeError: 'list' object has no attribute 'setValue'
... View more
01-28-2015
10:45 PM
|
0
|
0
|
6994
|
|
POST
|
Thats what I have so far with the help of dan and xander: The goal is to create an oldschool image catalog as dbf, because we use a software which can't read the new ones. import arcpy, os, math
from arcpy import env
Fgdb = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
arcpy.env.workspace = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
# Ausgabepfad = (r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster").strip()
Ausgabepfad = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster"
ext = ".jpg"
arcpy.AddField_management(Ausgabepfad + "\Orthos_Nummern.shp", "IMAGE", "TEXT", 100) # , "", "", "refcode", "NULLABLE", "REQUIRED")
ext = ".jpg"
fc = os.path.join(Ausgabepfad, "Orthos_Nummern.shp")
fld_oid = "OBJECT_ID" # or: arcpy.Describe(fc).OIDFieldName
fld_out = "IMAGE" # should exist in shapefile
fld_xmin = "XMIN"
arcpy.AddField_management(fc, "XMIN", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "XMAX", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "YMIN", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(fc, "YMAX", "LONG", 7) # , "", "", "refcode", "NULLABLE", "REQUIRED")
input_shp = fc
arr = arcpy.Array()
with arcpy.da.UpdateCursor(input_shp,['FID','SHAPE@']) as cur:
extents = []
for row in cur:
ext = row[1].extent
p0 = ext.lowerLeft; p1 = ext.upperRight
print('Extent of shape... {}: '.format(row[0]))
print(' X min/max {}, {}'.format(ext.XMin,ext.XMax))
Xmin = round((ext.XMin), 0)
print (Xmin)
print_attributes(row)
row.setValue(fld_xmin, Xmin)
print ( ' X min, {}'.format(ext.XMin))
curs.updateRow(row)
print(' Y min/max {}, {}'.format(ext.YMin,ext.YMax))
arr.add(p0)
arr.add(p1)
mp = arcpy.Multipoint(arr)
print('Extent of all {}'.format(mp.extent))
rows = arcpy.UpdateCursor(fc)
for row in rows:
fld_oid1 = int(row.getValue(fld_oid))
int_fld_oid1 = str(fld_oid1)
# path = os.path.join(Ausgabepfad, "{0}{1}".format(row.getValue(fld_oid), ext))
path = os.path.join(Ausgabepfad, int_fld_oid1 + ext)
print (path)
path1 = str("" + path + "")
row.setValue(fld_out, path)
rows.updateRow(row)
... View more
01-28-2015
10:44 PM
|
0
|
8
|
6994
|
|
POST
|
OK moved there: What means: TypeError: 'Row' object does not support indexing ???
... View more
01-28-2015
10:38 PM
|
0
|
0
|
2730
|
|
POST
|
Don't know how to get rid of that message? input_shp = fc
arr = arcpy.Array()
with arcpy.da.UpdateCursor(input_shp,['FID','SHAPE@']) as cur:
extents = []
for row in cur:
ext = row[1].extent
p0 = ext.lowerLeft; p1 = ext.upperRight
print('Extent of shape... {}: '.format(row[0]))
print(' X min/max {}, {}'.format(ext.XMin,ext.XMax))
Xmin = round((ext.XMin), 0)
print (Xmin)
row.setValue(fld_xmin, Xmin)
print ( ' X min, {}'.format(ext.XMin))
curs.updateRow(row)
print(' Y min/max {}, {}'.format(ext.YMin,ext.YMax))
arr.add(p0)
arr.add(p1)
mp = arcpy.Multipoint(arr)
print('Extent of all {}'.format(mp.extent))
... View more
01-28-2015
07:16 AM
|
0
|
3
|
10454
|
|
POST
|
rows1 = arcpy.SearchCursor(fc, ["SHAPE@"])
extents = []
for row1 in rows1:
ext = row1[0].extent
extents.append(row1[0].extent)
print(extents)
... View more
01-27-2015
11:57 PM
|
0
|
11
|
18105
|
|
POST
|
Unfortunately I can't use arcpy.da. 😞 Small mistake in your code: Not: curs.updateRow(row) It's ?: rows.updateRow(row) Had only to make the value to integer: fld_oid1 = int(row.getValue(fld_oid)) int_fld_oid1 = str(fld_oid1)
... View more
01-27-2015
11:23 PM
|
0
|
1
|
2763
|
|
POST
|
Look good Xander, unfortunaltely path = os.path.join(Ausgabepfad, "{0}{1}".format(row.getValue(fld_oid), ext)) leads to that: R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\35355481.0.jpg I would need it without .0 = xxx481.jpg ? and row.getValue = TypeError: 'float' object is not subscriptable ?
... View more
01-27-2015
05:31 AM
|
0
|
1
|
2763
|
|
POST
|
Thanks for help. If I try this: print (('R:\\Karto\Bierer2014\\Datenabgabe\\20150113_Brandt\\raster\\' + '(!OBJECT_ID!)' + ext).strip('utf-8')) I get this message: AttributeError: 'str' object has no attribute 'OBJECT_ID' I do understand that I haven't told python properly that it should take attribute of the field Objec_ID of the shape. How to do that. Also tried with no sucess: for row in rows: unique_values = set(row.getValue(Field) for row in iter(arcpy.SearchCursor(Path).next, None))
... View more
01-27-2015
03:56 AM
|
0
|
3
|
2763
|
|
POST
|
Somehow I can't manage to get this to work: The goal is to write a path into a field combined with the attribute Object_ID import arcpy, os
Fgdb = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
arcpy.env.workspace = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\RasterCatalog.gdb"
# Ausgabepfad = (r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster").strip()
Ausgabepfad = r"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster"
ext = ".jpg"
# arcpy.AddField_management(Ausgabepfad + "\Orthos_Nummern.shp", "IMAGE", "TEXT", 100) # , "", "", "refcode", "NULLABLE", "REQUIRED")
# print (Ausgabepfad + "\Orthos_Nummern.shp")
# print ("\"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\"" + ext)
# print (Ausgabepfad + "\\Orthos_Nummern.shp")
rows = arcpy.UpdateCursor(Ausgabepfad + "\Orthos_Nummern.shp")
for row in rows:
# yield ('"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\"' + '(!OBJECT_ID!)' + ext).strip()
# print (('"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\ + '(!OBJECT_ID!)' + 'ext').strip('utf-8'))
print (('R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\' + '(!OBJECT_ID!)' + 'ext').strip('utf-8'))
# arcpy.CalculateField_management(Ausgabepfad + "\\Orthos_Nummern.shp", "IMAGE",
('"R:\Karto\Bierer2014\Datenabgabe\20150113_Brandt\raster\"' + '(!OBJECT_ID!)' + ext).strip('utf-8'), "PYTHON") ???
... View more
01-27-2015
12:43 AM
|
0
|
9
|
6638
|
|
POST
|
strip() was the solution ... import shutil, os, sys # import numpy as np QFile = "R:\\natura 2000\\SG-Besprechungen\\Migration2015_Q_Test.txt" ZFile = "R:\\natura 2000\\SG-Besprechungen\\Migration2015_Z.txt" ##QFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Q.txt" ##ZFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Z.txt" f = open(QFile, 'r') for line in f: print(line) # print f.readline f1 = open(ZFile, 'r') for line1 in f1: print(line1) shutil.move(line.strip(), line1.strip())
... View more
01-16-2015
04:38 AM
|
0
|
0
|
777
|
|
POST
|
I do know it's not the python forum here around, but maybe someone knows that. Need a migration script to copy folders. That's what I have so far: import shutil, os, sys
# import numpy as np
QFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Q.txt"
ZFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Z.txt"
f = open(QFile, 'r')
for line in f:
print(line)
# print f.readline
f1 = open(ZFile, 'r')
for line1 in f1:
print(line1)
## src = line
## dest = r"R:\SG-C\SIC_20150115"
if sys.platform == 'win32':
os.system('xcopy "%s" "%s"' % (line, line1) + " /Y /M /S /E /D")
print 'xcopy "%s" "%s"' % (line, line1) + " /Y /M /S /E /D "
else:
shutil.copy(line, line1) Result is that: R:\natura 2000\8847.00 Richtlinien\Bauleitplanung R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000 xcopy "R:\natura 2000\8847.00 Richtlinien\Bauleitplanung " "R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000 " /Y /M /S /E /D R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern (Why that?) xcopy "R:\natura 2000\8847.00 Richtlinien\Bauleitplanung " "R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern " /Y /M /S /E /D R:\natura 2000\8847.02 allgemein R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000 (Double?) xcopy "R:\natura 2000\8847.02 allgemein " "R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000 " /Y /M /S /E /D R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern xcopy "R:\natura 2000\8847.02 allgemein " "R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern " /Y /M /S /E /D
... View more
01-16-2015
12:38 AM
|
0
|
1
|
4533
|
|
POST
|
Thanks Xander. Nontheless this was the best solution for me: if sys.platform == 'win32': os.system('xcopy "%s" "%s"' % (src, dest) + " /Y /M /S /E") else: shutil.copy(src, dest)
... View more
01-15-2015
01:29 AM
|
1
|
0
|
4780
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-10-2025 08:08 AM | |
| 1 | 05-13-2025 05:05 AM | |
| 1 | 04-28-2025 03:40 AM | |
| 4 | 08-13-2024 10:49 PM | |
| 1 | 08-13-2024 09:52 PM |
| Online Status |
Online
|
| Date Last Visited |
3 hours ago
|