How to use where clause with NumPyArray to Feature?

2764
1
04-06-2015 08:21 AM
GeoffreyWest1
New Contributor

I have a NumPyArray that I would like to use a where clause .  My workflow is if my first NumPyArray to feature fails then run another one with a where clause of data that has come into a json web-service in the past 10 minutes.    I would ideally like to implement a where clause in both scenarios.  Here is what I have:

arr = np.array(items,dtype=dt)
sr = arcpy.SpatialReference(4326)
NumPyArray = arcpy.da.NumPyArrayToFeatureClass(arr, fc, ['longitudeshape', 'latitudeshape'], sr)
#I would like to use a five minute whereclause here for my Date field.

cursor = arcpy.SearchCursor(fc,"""Date BETWEEN '2014-02-16 16:53:25' AND  '2015-02-17 16:53:25'""" )
for row in cursor:
 print(row.getValue("Date"))




if row.getValue("Date") < datetime.datetime.now():
    print "true"
else:
       "excecute numpy array for a 10 minute window."
0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

For starters, I encourage you to read up on and use cursors from the data access module.  The data access cursors are much more robust and efficient than the older style cursors.

Querying dates and times is highly specific to the storage format.  Have you read the SQL reference for query expressions used in ArcGIS, particularly the section on Dates and time?  What storage format are you working with?