|
POST
|
I'm sure to get in over my head, but it is one way to learn. So here goes... I believe this is a way to pass additional information to fsolve. It produces the same result as your code example. I think you are trying to send file, fixe and fize to the function, correct? These values would come from your raster files. import numpy as np
from scipy.optimize import fsolve
def myFunction(z, file, fixe, fize):
E = z[0]
G = z[1]
H = z[2]
F = np.empty((3,))
F[0] = (file/fize)*3*H*pow(abs(H),-(1/6))-G
F[1] = fixe-E-H-G
F[2] = file*H-E
return F
file = 3.356
fixe = 300
fize = 1.024
zGuess= np.array([1,1,1])
z = fsolve(myFunction, zGuess, args=(file,fixe,fize))
print z
#result: [ 70.96121951 207.89419779 21.14458269]
... View more
12-04-2017
01:28 PM
|
0
|
1
|
3000
|
|
POST
|
As a follow-up... It might be possible to get suggestions as to the identity of the join field by using some dictionaries. This would look at a row in each feature to see if there are multiple fields with the same value. Just a thought... for f in arcpy.mapping.ListLayers(mxd):
fields = []
field_info = arcpy.Describe(f).fieldInfo
for i in xrange(0,field_info.count):
fields.append(field_info.getfieldname(i))
with arcpy.da.SearchCursor(f, fields) as cursor:
values = cursor.next()
# make dictionary of fields and values
joinDict = dict(zip(fields, values))
# swap keys and values
revDict = {}
for key, value in joinDict.items():
revDict.setdefault(value, set()).add(key)
join_fields = [values for key, values in revDict.items() if len(values) > 1] # field names
field_value = [key for key, values in revDict.items() if len(values) > 1] # value in common
print "Possible joins: {}".format(join_fields)
print "Field value used: {}".format(field_value)
# Output:
# Possible joins: [set([u'Table1.TaID', u'Feature1.OBJECTID', u'Table1.OBJECTID'])]
# Field value used: [1.0]
... View more
12-03-2017
10:37 PM
|
0
|
4
|
3607
|
|
POST
|
Can you share the code you have been testing? I have not been able do duplicate your situation. I have been testing the following code both inside and outside ArcMap, and themap has a feature joined with a table that is listed in the map TOC and a second feature joined with a table that is not in the map TOC. It picks up all joined fields (as feature.field or table.field) of both features. The table path is only available when the table is in the TOC with ListTableViews. import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Path\To\JoinTest.mxd")
for f in arcpy.mapping.ListLayers(mxd):
field_info = arcpy.Describe(f).fieldInfo
for i in xrange(0,field_info.count):
print field_info.getfieldname(i)
print '====='
... View more
12-03-2017
07:33 PM
|
1
|
5
|
3607
|
|
POST
|
As a follow-up to my previous... Run a version on 10.2 with a try/except block and write the exceptions to a file. import os
from glob import glob
import arcpy
f = open('map_list.txt', 'w')
PATH = r'C:\Start\Here'
arcpy.env.workspace = PATH
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for map in result: # map will be complete path to map file
try:
mxd = arcpy.mapping.MapDocument(map)
#set relative paths property
mxd.relativePaths = True
#save map document change
mxd.save()
except:
# assume exceptions are version 10.3
f.write(map + '\n')
f.close() With 10.3 process the maps from the file, which are assumed to be 10.3. import arcpy
with open('map_list.txt') as f:
maps = f.readlines()
f.close()
# remove whitespace characters like `\n` at the end of each line
maps = [x.strip() for x in maps]
for map in maps:
try:
mxd = arcpy.mapping.MapDocument(map)
#set relative paths property
mxd.relativePaths = True
#save map document change
mxd.save() # current version (10.3)
mxd.saveACopy('modified map name',"10.1") # for older version
except:
print "Failed processing {}".format(map) By using mxd.saveACopy you could create a copy in version 10.1 (which is used by 10.2) by modifying the map document name. I did some experimenting with the code suggested at stack exchange, but it sometimes failed at getting the version number. It seems there is no consistent way to do this. Unfortunately, there is no map document property for file version.
... View more
12-02-2017
08:25 PM
|
1
|
0
|
2136
|
|
POST
|
And a second version on stack exchange: Checking .mxd version using ArcPy? Also of interest: How To: Save map documents in ArcGIS 10.x to previous version of ArcGIS in batch A try/except code block could work for the 10.2 version trying to open a 10.3 file.
... View more
12-01-2017
01:42 PM
|
1
|
1
|
2136
|
|
POST
|
First, check out FAQ: Is there a feature limit in ArcGIS Online? The limit generally applies as the maximum number of records that will be returned by the server. Since AGOL is a web service, retrieving too many records can cause the browser to have issues. When I want to keep the feature small, I will divide the features into areas and create individual maps for each area. You will need to share the feature with a group, and if the feature is used in a Collector map, the map must also be shared with the group. You will need to allow Create, Delete, Query, Sync and Update operations for the group to be able to make additions and updates. If you are publishing from ArcMap you will need to select Capabilities >> Feature Access to set these options. These options can also be modified after publishing.
... View more
11-30-2017
02:02 PM
|
1
|
0
|
1918
|
|
POST
|
I think it would be more like this, but I haven't tested the code: import os
from glob import glob
import arcpy
PATH = r'C:\Users\mclbr\Desktop\GIS_Maintenance'
arcpy.env.workspace = PATH
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for map in result: # map will be complete path to map file
print "Processing: {}".format(map) # keep track of what's happening
mxd = arcpy.mapping.MapDocument(map)
#set relative paths property
mxd.relativePaths = True
#save map doucment change
mxd.save() You can add some additional print statements to help keep track of what's happening and to assist with debugging. I'm not sure how the arcpy workspace plays into relative paths. You may need to move this into your for loop and set workspace equal to the path up to your mxd file.
... View more
11-29-2017
03:45 PM
|
2
|
0
|
2650
|
|
POST
|
Try this to find your mxd files: import os
from glob import glob
PATH = r'C:\Start\Here'
result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for mxd in result:
print mxd # continue here with processing your files
... View more
11-29-2017
12:11 PM
|
1
|
3
|
2650
|
|
POST
|
And if using a service like AGOL, you may also need to convert your date/time into UTC.
... View more
11-29-2017
10:06 AM
|
0
|
0
|
2089
|
|
POST
|
I believe your date/time needs to be in epoch time (Unix time) with milliseconds when using json formatting. "LeaseSigned" : 1480615200000
... View more
11-29-2017
09:39 AM
|
0
|
1
|
2089
|
|
POST
|
Assuming you are looking for an exact match, you might try: fc = 'CitiesAmtrak.shp'
field = 'NAME'
whereClause = "{} = '{}'".format(field,userInput)
if len(list(i for i in arcpy.da.SearchCursor(fc, [field],where_clause=whereClause))):
print "Found"
else:
print "Not found" Using fuzzy might offer other options, such as "Did you mean ....".
... View more
11-28-2017
07:19 PM
|
0
|
0
|
2762
|
|
POST
|
I think it is best to use the CSV module. If you just import the CSV directly, ArcMap will create its own field names and use the actual field names as an alias. Fixing the CSV gives you control over the field names that will be used. You can always add longer aliases later if you want.
... View more
11-27-2017
08:40 PM
|
0
|
0
|
12580
|
|
POST
|
As a follow-up to my suggestions previously, I am assuming you are reading the CSV file, correcting the header, and then writing a new CSV. Something like: import csv
import os
inputFileName = "test.csv"
outputFileName = os.path.splitext(inputFileName)[0] + "_modified.csv"
headersDict = {'NUMBER, SEX AND AGE - Total Population - Under 5 years': 'TPop00_05',
'NUMBER, SEX AND AGE - Total Population - 5 to 9 years': 'TPop05_09',
'NUMBER, SEX AND AGE - Total Population - 10 to 14 years': 'TPop10_14',
'NUMBER, SEX AND AGE - Total Population - 15 to 19 years': 'TPop15_19',
'NUMBER, SEX AND AGE - Total Population - 20 to 24 years': 'TPop20_24',
'NUMBER, SEX AND AGE - Total Population - 25 to 29 years': 'TPop25_29'
}
with open(inputFileName, 'rb') as inFile, open(outputFileName, 'wb') as outfile:
r = csv.reader(inFile)
w = csv.writer(outfile)
# read the first row from the reader, the old header
header = next(r)
print header
# replace items in header using dictionary, if item not in dictionary, it will not be replaced
newHeader = [ headersDict.get(item,item) for item in header ]
print newHeader
# write new header
w.writerow(newHeader)
# copy the rest
for row in r:
w.writerow(row) If not, can you describe your process.
... View more
11-26-2017
08:49 PM
|
1
|
2
|
12580
|
|
POST
|
In your first bit of code there is a semicolon after 'NUMBER', and in your latest response there is a comma. Replacing with this method will require an exact match. Extra spaces, long versus short dashes, and non-printable characters in your original csv header can cause problems. Also, since you are working with a CSV file, you need to make sure each item in the header row is properly quoted when there is a comma used.
... View more
11-25-2017
07:35 PM
|
0
|
0
|
12580
|
|
POST
|
Try this: headersDict = {'Number; SEX AND AGE - Total Population':'TPop',
'Number; SEX AND AGE - Male Population':'MPop',
'Number; SEX AND AGE - Female Population':'FPop',
'Under 5 years': '<5',
'5 to 9 years': '5_9',
'10 to 14 years': '10_14',
'15 to 19 years': '15_19',
'20 to 24 years': '20_24',
'25 to 29 years': '25_29',
'30 to 34 years': '30_34',
'35 to 39 years': '35_39',
'40 to 44 years': '40_44',
'45 to 49 years': '45_49',
'50 to 54 years': '50_54',
'55 to 59 years': '55_59',
'60 to 64 years': '60_64',
'65 to 69 years': '65_69',
'70 to 74 years': '70_74',
'75 to 79 years': '75_79',
'80 to 84 years': '80_84',
'85 years and over': '85+',
'Median age(years)': 'Medage',
'16 years and over': '16+',
'18 years and over': '18+',
'21 years and over': '21+',
'62 years and over': '62+',
'65 years and over': '65+'}
headersList = [ '10 to 14 years',
'15 to 19 years'
]
# list comprehension
headersList = [ headersDict.get(item,item) for item in headersList ]
print headersList Several of the values in the dictionary may be problematic as field names. "Under 5", "16 and over", etc. use symbols that may cause issues. There may also be a problem in starting field names with a number. See: FAQ: What characters should not be used in ArcGIS for field names and table names?
... View more
11-24-2017
07:19 PM
|
1
|
5
|
12580
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
07:13 PM
|