arcpy

how to create datetime from a negative epoch in Python

Deadly 提交于 2019-12-01 17:46:32
First timer on StackExchange. I am working with ArcGIS Server and Python. While trying to execute a query using the REST endpoint to a map service, I am getting the values for a field that is esriFieldTypeDate in negative epoch in the JSON response. The JSON response looks like this: { "feature" : { "attributes" : { "OBJECTID" : 11, "BASIN" : "North Atlantic", "TRACK_DATE" : -3739996800000, } , "geometry" : { "paths" : [ [ [-99.9999999999999, 30.0000000000001], [-100.1, 30.5000000000001] ] ] } } } The field I am referring to is "TRACK_DATE" in the above JSON. The values returned by ArcGIS

How to run external executable using Python?

╄→гoц情女王★ 提交于 2019-11-30 11:18:59
I have an external executable file which i am trying to run from a Python script. CMD executable runs but without generating output. Probably it exit before output can be generated. Any suggestion about how to delay exit until outputs are generated? import subprocess, sys from subprocess import Popen, PIPE exe_str = r"C:/Windows/System32/cmd C:/temp/calc.exe" parent = subprocess.Popen(exe_str, stderr=subprocess.PIPE) use subprocess.call , more info here : import subprocess subprocess.call(["C:\\temp\\calc.exe"]) or import os os.system('"C:/Windows/System32/notepad.exe"') i hope it helps you...

Importing arcpy module into anaconda's Spyder

跟風遠走 提交于 2019-11-30 05:26:14
问题 I would like to use arcpy into Anaconda's Spyder. I have a full ArcGIS license, so this is not an issue. I am able to semi-import the module by way of copying the the arcpy folder out of C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy and into C:\Anaconda\Lib\site-packages, but the import is never completed because I get an error of "ImportError: No module named arcgisscripting". Is there any way for arcpy to work in Spyder? 回答1: This is what you need to do: Open the Python window in ArcGIS,

Find if a value exists in a column in Excel using python

馋奶兔 提交于 2019-11-29 12:49:24
I have an Excel file with one worksheet that has sediment collection data. I am running a long Python script. In the worksheet is a column titled “CollectionYear.” Say I want the year 2010. If the year 2010 exists in the “CollectionYear” column, I want the rest of the script to run, if not then I want the script to stop. This seems like an easy enough task but for the life of me I cannot figure it out nor find any examples. Any help would be greatly appreciated. I use xlrd all the time and it works great for me. Something like this might be helpful from xlrd import open_workbook def main():

python dict to numpy structured array

亡梦爱人 提交于 2019-11-28 17:14:19
I have a dictionary that I need to convert to a NumPy structured array. I'm using the arcpy function NumPyArraytoTable , so a NumPy structured array is the only data format that will work. Based on this thread: Writing to numpy array from dictionary and this thread: How to convert Python dictionary object to numpy array I've tried this: result = {0: 1.1181753789488595, 1: 0.5566080288678394, 2: 0.4718269778030734, 3: 0.48716683119447185, 4: 1.0, 5: 0.1395076201641266, 6: 0.20941558441558442} names = ['id','data'] formats = ['f8','f8'] dtype = dict(names = names, formats=formats) array=numpy

Find if a value exists in a column in Excel using python

孤者浪人 提交于 2019-11-28 06:10:38
问题 I have an Excel file with one worksheet that has sediment collection data. I am running a long Python script. In the worksheet is a column titled “CollectionYear.” Say I want the year 2010. If the year 2010 exists in the “CollectionYear” column, I want the rest of the script to run, if not then I want the script to stop. This seems like an easy enough task but for the life of me I cannot figure it out nor find any examples. Any help would be greatly appreciated. 回答1: I use xlrd all the time

python dict to numpy structured array

血红的双手。 提交于 2019-11-27 10:18:50
问题 I have a dictionary that I need to convert to a NumPy structured array. I'm using the arcpy function NumPyArraytoTable, so a NumPy structured array is the only data format that will work. Based on this thread: Writing to numpy array from dictionary and this thread: How to convert Python dictionary object to numpy array I've tried this: result = {0: 1.1181753789488595, 1: 0.5566080288678394, 2: 0.4718269778030734, 3: 0.48716683119447185, 4: 1.0, 5: 0.1395076201641266, 6: 0.20941558441558442}