|
POST
|
You can set your feature to Record GPS metadata. The fields ESRIGNSS_LATITUDE and ESRIGNSS_LONGITUDE will contain lat/lon if you are collecting using GPS location. If you click on the screen and select "Collect here" the fields will be left blank. Tagging https://community.esri.com/community/gis/applications/collector-for-arcgis
... View more
02-12-2018
07:48 PM
|
3
|
0
|
2493
|
|
POST
|
Blake Terhune's code should let you add a date to the name of zip files in a directory. When I use a date in a filename, I usually format it in year-month-day order as it can be useful when you sort the listing in a file folder. time.strftime('%y%m%d') # YYMMDD order
... View more
02-07-2018
07:46 PM
|
2
|
0
|
6919
|
|
POST
|
Should ParcelNum be included in both updateFieldsList and sourceFieldsList? Also, if you are trying to set the size of the text fields for AddField, I think the value should be moved over a bit: # AddField_management (in_table, field_name, field_type, {field_precision}, {field_scale}, {field_length}, {field_alias}, {field_is_nullable}, {field_is_required}, {field_domain})
fields = [
("PermitNum","Text","30","","","","NULLABLE","NON_REQUIRED",""),
# should be
("PermitNum","Text","","","30","","NULLABLE","NON_REQUIRED",""),
... View more
02-07-2018
10:11 AM
|
0
|
1
|
2430
|
|
POST
|
Although these examples work with a file geodatabase, they may give you some ideas. If the Waze xml uses the GPX format, you could use the GPX To Features tool. I use this script to convert a number of GPX files to features: import glob, os
import arcpy
import datetime
gpxPath = r"C:\Path\to\gpx\directory"
gdb = r'C:\Path\to\file.gdb'
arcpy.env.workspace = gdb
os.chdir(gpxPath)
print datetime.datetime.now()
for gpx in glob.glob("*.gpx"):
gpxStr = filter(str.isdigit, gpx)
gpxStr = 'GPX_'+gpxStr[2:8]+'_'+gpxStr[8:] # my filename included a date/time
print gpxStr
arcpy.GPXtoFeatures_conversion(Input_GPX_File=gpxPath+gpx, Output_Feature_class=gpxStr)
for i in range(0,arcpy.GetMessageCount()):
print arcpy.GetMessage(i)
Many of my GPX files are created by the logging function built into the Bad Elf Pro GPS. The XML file includes some additional extensions that the GPXtoFeatures tool will not import. So I use the following to convert the XML into a feature, which uses steps outlined by James MacKay: # import Bad Elf track from GPX xml file and save as file geodatabase feature
import xml.etree.ElementTree as ET
import re
import arcpy
from arcpy import env
# geodatabase and environment to use
geoDB = r"C:\Path\To\file.gdb"
env.workspace = geoDB
ns = { 'gpx': 'http://www.topografix.com/GPX/1/1',
'elf': 'http://bad-elf.com/xmlschemas' }
# name for feature layer from xml
for trk in tree.findall('gpx:trk', ns):
feature = trk.find('gpx:name', ns).text
feature = 'BE_'+' '.join(re.sub('[^0-9a-zA-Z ]', '', feature.strip()).split())
# create feature
print "\nCreating feature: " + feature
geometry_type = "POINT"
tree = ET.parse(r"C:\Path\To\bad-elf.gpx') # xml file
template = "#"
has_m = "DISABLED"
has_z = "DISABLED"
spatial_reference = arcpy.SpatialReference("WGS 1984")
arcpy.CreateFeatureclass_management(geoDB, feature, geometry_type, template, has_m, has_z, spatial_reference)
# add fields
arcpy.AddField_management(feature,'TimeString','TEXT','#','#','20','Date and Time','Nullable','NON_REQUIRED')
arcpy.AddField_management(feature,'HDOP','DOUBLE','#','#','#','HDOP','Nullable','NON_REQUIRED')
arcpy.AddField_management(feature,'Speed','DOUBLE','#','#','#','Speed','Nullable','NON_REQUIRED')
arcpy.AddField_management(feature,'EleGPS','DOUBLE','#','#','#','GPS Elevation','Nullable','NON_REQUIRED')
arcpy.AddField_management(feature,'EleBP','DOUBLE','#','#','#','BP Elevation','Nullable','NON_REQUIRED')
arcpy.AddField_management(feature,'BP','DOUBLE','#','#','#','Barometric Pressure','Nullable','NON_REQUIRED')
# open an insert cursor
cursor = arcpy.da.InsertCursor(feature, ['TimeString', 'HDOP', 'Speed', 'EleGPS', 'EleBP', 'BP', 'SHAPE@XY'])
# read xml and insert into feature
for trkseg in tree.findall('gpx:trk', ns):
for trkpt in trkseg.find('gpx:trkseg', ns):
ts = trkpt.find('gpx:time', ns).text
hd = float(trkpt.find('gpx:hdop', ns).text)
sp = float(trkpt.find('gpx:extensions/elf:speed', ns).text)
el = float(trkpt.find('gpx:ele', ns).text)
be = float(trkpt.find('gpx:extensions/elf:baroEle', ns).text)
bp = float(trkpt.find('gpx:extensions/elf:baroPress', ns).text)
row = (ts, hd, sp, el, be, bp, (float(trkpt.attrib['lon']), float(trkpt.attrib['lat'])))
print row
cursor.insertRow(row)
#delete the cursor to finish
del cursor
print "Done." Here's a sample of the Bad Elf XML used: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"
xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
xmlns:badelf="http://bad-elf.com/xmlschemas"
version="1.1"
creator="Bad Elf GPS Pro+ 2.1.44"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd http://bad-elf.com/xmlschemas http://bad-elf.com/xmlschemas/GpxExtensionsV1.xsd">
<metadata>
<extensions>
<badelf:modelNickname>Bad Elf GPS Pro+</badelf:modelNickname>
<badelf:modelSerialNumber>007</badelf:modelSerialNumber>
<badelf:modelName>Bad Elf GPS Pro+</badelf:modelName>
<badelf:modelNumber>BE-GPS-2300</badelf:modelNumber>
<badelf:modelHardwareRevision>8.0.0</badelf:modelHardwareRevision>
<badelf:modelFirmwareRevision>2.1.44</badelf:modelFirmwareRevision>
<badelf:elevationSource>gps</badelf:elevationSource>
</extensions>
</metadata>
<wpt lat="1.306545" lon="1.408652">
<ele>95.8</ele>
<time>2017-09-21T02:46:58Z</time>
<name>START (2017-09-21T02:46:58Z)</name>
</wpt>
<trk>
<name>2017-09-21T02:46:58Z</name>
<trkseg>
<trkpt lat="1.306545" lon="1.408652">
<ele>95.8</ele>
<time>2017-09-21T02:46:58Z</time>
<hdop>1.2</hdop>
<extensions>
<badelf:speed>0.77</badelf:speed>
<badelf:baroEle>74.10</badelf:baroEle>
<badelf:baroPress>1007.31</badelf:baroPress>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx> Hope this helps.
... View more
02-05-2018
10:09 PM
|
2
|
0
|
5657
|
|
POST
|
Do you have python code to read the XML, or are you just interested in the ODBC connection portion?
... View more
02-03-2018
12:12 PM
|
0
|
2
|
5657
|
|
POST
|
Since search_feats is set using list comprehension, you might want to check out Dan Patterson's blogs on the topic: List comprehensions... List comprehensions... 2 List comprehensions 3 ... (And Dan has lots of other interesting Python postings)
... View more
02-01-2018
10:17 AM
|
1
|
1
|
6361
|
|
POST
|
That is probably related to how you are importing the datetime modules. # insead of
import datetime
if rec[dt_i] and datetime.datetime.now() - rec[dt_i] <= datetime.timedelta(30))
# use this
from datetime import datetime, timedelta
if rec[dt_i] and datetime.now() - rec[dt_i] <= timedelta(30)) The second method of importing modules will save some typing and make the code easier to read, as illustrated in lines 5 and 11 above.
... View more
02-01-2018
10:09 AM
|
2
|
1
|
1963
|
|
POST
|
datefield can be a list in line 9, but not in line 10. Try: datefield = ['LASTUPDATE'] # list
with arcpy.da.SearchCursor(fc1, datefield) as cur:
dt_i = cur.fields.index(datefield[0]) # first element in list
# or - as in Joshua's original code
datefield = ['LASTUPDATE']
dt_fld = 'LASTUPDATE'
with arcpy.da.SearchCursor(fc1, datefield) as cur:
dt_i = cur.fields.index(dt_fld)
... View more
02-01-2018
09:17 AM
|
0
|
3
|
1963
|
|
POST
|
Since you want to add several values to each dictionary key, you need to use f[0]:f[1:]. The colon is used for slicing and [1:] is equivalent to "1 to end". You may also wish to put your field names into a variable if both the search cursor and update cursor are working with the same field names. If the field types are the same in both tables, you shouldn't need to cast types. Hope this helps. flds = ["KEY_FIELD","FIELD_2","FIELD_3"]
search_feats = {f[0]:f[1:] for f in arcpy.da.SearchCursor(Table_1,flds)}
with arcpy.da.UpdateCursor(Table_2,flds) as upd_cur:
... View more
01-31-2018
07:29 PM
|
1
|
0
|
6361
|
|
POST
|
bixb0012, thanks for sharing the code. It has been added to my snippets collection.
... View more
01-31-2018
06:37 PM
|
0
|
0
|
364
|
|
POST
|
Just use ASC, which is the default. See this for more info: SQL reference for query expressions used in ArcGIS
... View more
01-31-2018
12:04 PM
|
1
|
0
|
8554
|
|
POST
|
As Dan Patterson suggests, you need to use the sql_clause in the search cursor: for row in arcpy.da.SearchCursor(intable, "ContestTitle", sql_clause=(None,'ORDER BY ContestTitle DESC'):
... View more
01-31-2018
09:36 AM
|
1
|
2
|
8554
|
|
POST
|
One possible way with Python: from datetime import datetime, timedelta
daysAgo30 = datetime.now() - timedelta(days=30)
dateSearch = "dateField > date '{}'".format(datetime.strftime(daysAgo30,"%Y-%m-%d %H:%M:%S"))
result: "dateField > date '2017-12-31 15:35:32'" The format for the where clause will vary depending on the type of database used. You may want to format only for Y-D-M, omitting the time part. Code above should work for a file geodatabase. See also: SQL reference for query expressions used in ArcGIS
... View more
01-30-2018
04:41 PM
|
1
|
1
|
4326
|
|
POST
|
You might try: MaxOID = next(arcpy.da.SearchCursor(scratchFC, ['OBJECTID'], sql_clause=(None,'ORDER BY OBJECTID DESC')))
print MaxOID[0] # use first element
... View more
01-30-2018
10:55 AM
|
2
|
4
|
3566
|
|
POST
|
In my previous response, I used the old InsertCursor. Try the da.InsertCursor, and since it is only one field, not a tuple, just one set of () around row. cursor = arcpy.da.InsertCursor("Table_2",['FieldA'])
for row in tbList:
cursor.insertRow([row]) # as Bixby suggested below, using square brackets
del cursor
... View more
01-30-2018
10:36 AM
|
0
|
3
|
4860
|
| 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
|