|
POST
|
If I do this it prints the fc name of the shape in the last folder of the txt file and correctly the name of the shape + "_E.shp" as the projected shapefile?
... View more
07-31-2017
04:37 AM
|
0
|
2
|
2354
|
|
POST
|
The following python code should read out of a text file folder paths and project the shapefiles in this folder. Unfortunately this works only with the last (folder) line? Any suggestions why this doesn't work? # Import arcpy module
import arcpy, os
fname = r"H:\python_scripte\ProjizierenMulti\test.txt"
with open(fname) as f:
for line in f:
print line
arcpy.env.workspace = line
workspace = arcpy.env.workspace
arcpy.env.overwriteOutput = True
# Use the ListFeatureClasses function to return a list of
# shapefiles.
featureclasses = arcpy.ListFeatureClasses()
# Copy shapefiles to a file geodatabase
for fc in featureclasses:
print "Projiziere " + fc
outfile = os.path.splitext(fc)[0] + "_E.shp"
spatialRef = arcpy.Describe(fc).spatialReference
print spatialRef.name
Ftype = arcpy.Describe(fc).datatype
print Ftype
if Ftype == "ShapeFile":
if spatialRef.name == "DHDN_3_Degree_Gauss_Zone_3":
arcpy.Project_management(fc, outfile, "PROJCS['ETRS_1989_UTM_Zone_32N_8stellen',GEOGCS['GCS_ETRS_1989',DATUM['D_ETRS_1989',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',32500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',9.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "DHDN_To_ETRS_1989_3", "PROJCS['DHDN_3_Degree_Gauss_Zone_3',GEOGCS['GCS_Deutsches_Hauptdreiecksnetz',DATUM['D_Deutsches_Hauptdreiecksnetz',SPHEROID['Bessel_1841',6377397.155,299.1528128]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Gauss_Kruger'],PARAMETER['False_Easting',3500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',9.0],PARAMETER['Scale_Factor',1.0],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]")
f.close()
... View more
07-31-2017
01:12 AM
|
0
|
8
|
2796
|
|
POST
|
Maybe you can use buffer tool with the option endtype flat and then process further to cut the polygon to the lenght of the line?
... View more
08-08-2016
11:11 PM
|
0
|
1
|
4376
|
|
POST
|
Can't find the possibility to change a discussion to a question?
... View more
08-08-2016
06:56 AM
|
0
|
2
|
2236
|
|
POST
|
## Load Data
import arcpy
import os
workspace = r"R:\Daten\geo_daten_Kopie"
out_workspace = r"R:\Karto\Bierer2016\OrdnerRDatenGeodatenBereinigen\SIC_Geodaten.gdb\data"
import arcpy
import os
feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="FeatureClass"): ##, type="Polygon"):
for filename in filenames:
feature_classes.append(os.path.join(dirpath, filename))
name = os.path.join(dirpath, filename)
print name
BaseName = os.path.basename(name)
print BaseName
BaseNameCopy = BaseName.split(".shp")
print BaseNameCopy
arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy)) The code leads to this error message: Traceback (most recent call last): File "H:/python_scripte/ListFolderandShapes/ListFeatures_FoldersSubfolders_CopyFeatures_3.py", line 22, in <module> arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy)) File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 73, in join elif isabs(b): File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 58, in isabs return s != '' and s[:1] in '/\\' TypeError: 'in <string>' requires string as left operand, not list Anyone has got an idea for a better solution?
... View more
08-08-2016
06:50 AM
|
0
|
2
|
1283
|
|
POST
|
Ah ok, didn't get this detail. Will post it again as a question. I think if FC Basson answers again the same he will get the points ...
... View more
08-08-2016
06:45 AM
|
0
|
2
|
2236
|
|
POST
|
## Load Data
import arcpy
import os
workspace = r"R:\Daten\geo_daten_Kopie"
out_workspace = r"R:\Karto\Bierer2016\OrdnerRDatenGeodatenBereinigen\SIC_Geodaten.gdb\data"
import arcpy
import os
feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="FeatureClass"): ##, type="Polygon"):
for filename in filenames:
feature_classes.append(os.path.join(dirpath, filename))
name = os.path.join(dirpath, filename)
print name
BaseName = os.path.basename(name)
print BaseName
BaseNameCopy = BaseName.split(".shp")
print BaseNameCopy
arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy)) The code leads to this error message: Traceback (most recent call last): File "H:/python_scripte/ListFolderandShapes/ListFeatures_FoldersSubfolders_CopyFeatures_3.py", line 22, in <module> arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy)) File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 73, in join elif isabs(b): File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 58, in isabs return s != '' and s[:1] in '/\\' TypeError: 'in <string>' requires string as left operand, not list Anyone has got an idea for a better solution?
... View more
08-08-2016
06:20 AM
|
0
|
8
|
3115
|
|
POST
|
Doen't work with integer or number fields, obviously
... View more
07-21-2016
02:58 AM
|
0
|
0
|
1253
|
|
POST
|
Attribute field must be a string defined field and it's all right
... View more
07-21-2016
02:58 AM
|
0
|
1
|
1253
|
|
POST
|
Error message in script which worked correctly days before? Any ideas why? line 16, in <module> quercy = field + "=" + "'" + Loop1 + "'" TypeError: cannot concatenate 'str' and 'int' objects import arcpy
import os
input = arcpy.GetParameterAsText(0)
clipfeature = arcpy.GetParameterAsText(1)
output = arcpy.GetParameterAsText(2)
clipfeature_Layer = "clipfeature_Layer"
arcpy.env.workspace = output
arcpy.env.overwriteOutput = True
field = "BFN_NR"
inputSp = input.split(";")
arcpy.MakeFeatureLayer_management(clipfeature, clipfeature_Layer, "", "", "")
cursor = arcpy.SearchCursor(clipfeature)
for row in cursor:
arcpy.AddMessage(row.getValue(field))
Loop1 = row.getValue(field)
quercy = field + "=" + "'" + Loop1 + "'"
arcpy.SelectLayerByAttribute_management (clipfeature_Layer, "NEW_SELECTION", quercy)
Sel_shape = "Sel_" + Loop1 + ".shp"
arcpy.CopyFeatures_management(clipfeature_Layer, Sel_shape)
for i in inputSp:
arcpy.AddMessage(i)
arcpy.Clip_analysis(i, Sel_shape, "Clip_" + row.getValue(field) + "_" + i)
... View more
07-20-2016
10:13 PM
|
0
|
4
|
2756
|
|
POST
|
Would like to mark your answer as the correct one, but there's only helpful and like buttons. Sorry wasn't here for a long time?
... View more
04-11-2016
07:16 AM
|
0
|
3
|
2574
|
|
POST
|
Thank you for your comment, but your idea leads to this: (u'R:\\Daten\\geo_daten\\GEOLOGIE\\bodenuebersicht\\daten\\arcview\\bodeneigenschaften\\shape\\bodeneigenschaften.shp',) Traceback (most recent call last): arcpy.CopyFeatures_management(line, os.path.join(OutPath,os.path.basename(line))) File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 198, in basename return split(p)[1] File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 170, in split d, p = splitdrive(p) File "C:\Python27\ArcGIS10.2\lib\ntpath.py", line 125, in splitdrive if p[1:2] == ':': IndexError: invalid index
... View more
04-11-2016
06:01 AM
|
0
|
2
|
2574
|
|
POST
|
I've a table with paths like: R:\Daten\geo_daten\GEOLOGIE\bodenuebersicht\daten\arcview\bodeneigenschaften\shape\bodeneigenschaften.shp and want to copy this Feature somewhere else and delete in the location where it is? What's wrong? import arcpy, numpy
arcpy.env.overwriteOutput = True
InPath = r"R:\Karto\Geodaten_Archiv.txt"
OutPath = r"R:\Daten\geo_daten\geodaten_archiv\SIC_2016_04_07"
filename = open(InPath, 'r')
arr = arcpy.da.TableToNumPyArray(InPath, "Datenpfad")
for line in arr:
print line
arcpy.CopyFeatures_management(line, OutPath)
... View more
04-11-2016
05:22 AM
|
0
|
11
|
5330
|
|
POST
|
Don't really get it? I would like to calculate cross direction profile of one line with a dem?
... View more
11-18-2015
05:05 AM
|
0
|
2
|
3294
|
| 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 |
4 hours ago
|