POST
|
Stuck for a long time, solved after few hours after posting into forum Two adjustments: - index and replaceFieldMap - new "instance" of output field object import arcpy
# input geodatabase
gdb=r"C:\Temp\EXPORT\export.gdb"
# output folder
folder=r"C:\Temp\EXPORT"
# dictionary - string in old name defines new name
fldsNamesDict={'String1':'NewName1','String2':'NewName2','String3':'NewName3','String4':'NewName4'}
# list of strings
fldsNames=list(fldsNamesDict.keys())
arcpy.env.workspace=gdb
fcs=arcpy.ListFeatureClasses()
# loop over feature classes
for fc in fcs:
# new fieldmappings object
fieldmappings=arcpy.FieldMappings()
# load input fc to fieldmappings object
fieldmappings.addTable(fc)
# fields of input fc
flds=fieldmappings.fieldMappings
# INDEX
i=0
# loop over fields
for fld in flds:
# loop - which string from dictionary is in old field name? what will be new name?
for fldName in fldsNames:
if fldName in fld.getInputFieldName(0):
# SET NEW FIELD NAME
of=fld.outputField
of.name=fldsNamesDict[fldName]
fld.outputField=of
# REPLACE FIELDMAP
fieldmappings.replaceFieldMap (i, fld)
# INCREASING INDEX
i=i+1
# export fc to shp using field mapping with new fields names
arcpy.FeatureClassToFeatureClass_conversion(fc,folder,fc+".shp","",fieldmappings)
... View more
07-15-2015
07:21 AM
|
4
|
0
|
1134
|
POST
|
Hi. I´m sure it is easy, but I just can´t make it work... What I need is to rename fields while exporting feature class to shapefile. There are strings in fields names, that define new names - I want to use dictionary. I know I have to use field mapping. But when I try to overwrite name of output field, it just does not work (names are not overwritten). How to do it? Sample code: import arcpy
# input geodatabase
gdb=r"C:\Temp\EXPORT\export.gdb"
# output folder
folder=r"C:\Temp\EXPORT"
# dictionary - string in old name defines new name
fldsNamesDict={'String1':'NewName1','String2':'NewName2','String3':'NewName3','String4':'NewName4'}
# list of strings
fldsNames=list(fldsNamesDict.keys())
arcpy.env.workspace=gdb
fcs=arcpy.ListFeatureClasses()
# loop over feature classes
for fc in fcs:
# new fieldmappings object
fieldmappings=arcpy.FieldMappings()
# load input fc to fieldmappings object
fieldmappings.addTable(fc)
# fields of input fc
flds=fieldmappings.fieldMappings
# loop over fields
for fld in flds:
# loop - which string from dictionary is in old field name? what will be new name?
for fldName in fldsNames:
if fldName in fld.getInputFieldName(0):
# SET NEW FIELD NAME
fld.outputField.name=fldsNamesDict[fldName]
# export fc to shp using field mapping with new fields names
arcpy.FeatureClassToFeatureClass_conversion(fc,folder,fc+".shp","",fieldmappings) Thanks for any help!
... View more
07-15-2015
02:03 AM
|
0
|
3
|
4633
|
POST
|
Hi, I am having this issue with Collector - when trying to edit offline, it is not possible to save created feature. It is possible to create feature (choose template, set location, fill the attributes), but when I tap the "OK mark" (top left corner), the feature disappears! No error or warning message is shown, the feature simply disappears. It is the same when trying to copy feature (that has been created before) - copying and editing works, when trying to save feature it disappears. It works online without any problem. Have you ever seen this error? I hope Russell Roberts or someone from his team will help... According to previous issue (Collector crash - offline, copy feature ) I have created AGOL group, shared the web map with that group and invited Collector4ArcGIS into that group. Collector for ArcGIS 10.3 (1010) Android 4.4.2 Samsung Galaxy Note 10.1 (SM-P605) feature services from own ArcGIS Server 10.2.2 Thank you!
... View more
03-12-2015
07:39 AM
|
0
|
1
|
2767
|
POST
|
OK, thanks! But - can you be more specific? 1. What do you mean when you are saying "very soon"? Do you know exact date? Days, weeks (months)? 2. Is it even possible to say more than "issue with one of the ET field"? Which field, how to avoid it?
... View more
01-27-2015
12:26 AM
|
0
|
2
|
738
|
POST
|
Great! So, what do you think? Something wrong in data, or with map service, or web map, or is it collector´s bug?
... View more
01-22-2015
11:08 PM
|
0
|
4
|
738
|
POST
|
As I was trying to explain - there are some more important steps to repro the issue are: 1. download map 2. turn off wifi 3. turn the device off 4. turn the device on, do not turn on wifi 5. being offline, open map 6. identify feature 7. through the result or the popup tap on the overflow option 8. tap on "Copy" 9. app should crash at this point
... View more
01-22-2015
12:18 PM
|
0
|
6
|
738
|
POST
|
Hi Russ, 1. Android 4.4.2, Samsung Galaxy Note 10.1 (SM-P605) 2. Group has been created, map has been shared, you have been invited... Let me know whether everything is set correctly. After some further "research" I have found a way how to bring up the problem - it appears after turning the internet access off and restarting the device (or clearing the RAM). When I just disconnect the device and start using Collector offline (without restarting the device or clearing the RAM), it works. So it seems to me that the problem is related to RAM. (?) You may be wondering why I want to restart the device. I don´t mean a "real-time" restart, but turning the device off and turning it on later (next day, etc.)... Lets say that users will use the device/app once a week. So the required "workflow" is: day 1: in the office - get connected, download area, disconnect, turn the device off; day 2: in the field - turn the device on, collect data offline. Is this explanation sufficient? BTW - Thank you, I really appreciate your attitude to solving problems this way on the forum. This is much more effective than "standard" way! EDIT: I am observing a very strange behaviour - having the problem described earlier, when I turn on the internet connection, the problem disappear and Collector is working properly (both on-line and off-line)! To obtain the problem again, it is necessary to clear RAM/restart device... BUT - this is not a solution! There will be situations when it will not be possible to get connection. I have sent a few standard "crash reports" with system info, I hope it will help. Does it even go to ESRI (as I hope), or is it just some Google stuff?
... View more
01-22-2015
01:20 AM
|
0
|
8
|
738
|
POST
|
Hi, I am struggling with this issue - when editing offline and trying to copy feature, app crashes. It crashes when clicking on the "Copy"; the copy dialogue does not even show up. I did not find any situation bringing the problem, it seems to crashes randomly. It does not appear every time, most of the time it is possible to copy feature at the beginning. But when the problem occurs, it is not possible to copy any feature (when starting app again). Thanks for your help!
... View more
01-21-2015
08:14 AM
|
0
|
10
|
5346
|
POST
|
Hi! I need to make a little geoprocessing service based on python script... Meaning of the service is easy: receive JSON, look if there are any features of one feature class in geodatabase and return the count of features... General idea of script (as it looks like as a desktop script - thats why there are "AddMessage") is this: import arcpy data="Database Connections\myDB.sde\MYDB.DATAOWNER.data" data_fl=arcpy.MakeFeatureLayer_management(data) json=arcpy.GetParameter(0) sr=arcpy.Describe(vo).spatialReference polygon=arcpy.AsShape(json,True) polygon.projectAs(sr) polygon_fl=arcpy.MakeFeatureLayer_management(polygon) arcpy.SelectLayerByLocation_management(data_fl,"INTERSECT",polygon) if arcpy.GetCount_management(data_fl).getOutput(0)!="0": arcpy.arcpy.AddMessage("you have chosen "+arcpy.GetCount_management(data_fl).getOutput(0)+" features") else: arcpy.arcpy.AddMessage("no chosen features") But - I know this is not way how to get some results from geoprocessing service (if i publish this script). How to force python script (=geoprocessing service) to return results??? It must be easy, I think this is kind of "newbie" question, Im still learning... Thanks for any help!
... View more
10-16-2014
08:40 AM
|
0
|
1
|
2964
|
POST
|
Thank you. I´ve tested arcpy.AsShape(), but I don´t know how to select features with that polygon... ??? I know it must be something easy, but I can´t solve it...
... View more
09-12-2014
12:15 AM
|
0
|
1
|
668
|
POST
|
HI! I´m a bit stuck with this easy trouble... I need to make a geoprocessing service, it will take JSON geometry, select features in database and answer questions like "are there any features/how many features/witch features are in that JSON polygon. Im not able to find out how to write python script to select features by JSON... Any advise? Thank you!
... View more
09-11-2014
08:51 AM
|
0
|
3
|
4326
|
POST
|
Hi! I need to make a script that does something like "zoom to/locate" = in ArcMap, user types a ID of an feature and map zooms to the feature... It needs to be independent on data in current mxd. My idea is to do it like this: import arcpy
dtb="Database Connections\mygdtb.sde"
arcpy.env.workspace=dtb
searchedLayer="MYGDTB.DATAOWNER.searchedLayer"
searchedValue=arcpy.GetParameterAsText(0)
sql="[searchedField]='"+searchedValue+"'"
lyr=arcpy.MakeFeatureLayer_management(searchedLayer, "lyr")
selectedItem=arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",sql) and than use layer´s method getSelectedExtent, than pass that extent to current mxd and zoom it to that extent... But it doesn´t work that way - I´m not able to get extent of selected features.... How to do it? Any ideas? I would appreciate any help... Thank you!
... View more
04-02-2014
05:41 AM
|
0
|
0
|
570
|
POST
|
Hi! Kind of newbie with web server, so be patient:) Using Viewer for Flex on IIS 8 I´m stuck on this issue - how to "forbid" users to view configuration files? I mean - my viewer for flex is available on www.myserver/com/app , calling index.html from www.myserver.com/app/index.html and so on. If user is "curious", he can view my config.xml on www.myserver.com/app/config.xml - how to disable it? I would like him to see just index.html and not to be able to see other files (but the app still has to work!). Is it possible? How? Thank you!
... View more
02-05-2014
11:16 PM
|
0
|
1
|
821
|
POST
|
Omg, I´m so sorry! I´ve read the pdf many times, but haven´t noticed this tag... Thank you for "kick"!
... View more
12-12-2013
04:38 AM
|
0
|
0
|
316
|
Title | Kudos | Posted |
---|---|---|
4 | 07-15-2015 07:21 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|