def csvToLayer(path, name): arcpy.AddMessage('csvToLayer()') return arcpy.XYTableToPoint_management( path, name, 'X', 'Y', coordinate_system=arcpy.SpatialReference('British National Grid'))
def createXYEvent(in_table, output): x_field = 'Longitude' y_field = 'Latitude' z_field = '' # 4283 is the code for: # GCS_GDA_1994 (Meters) coordinate_system = arcpy.SpatialReference(4283) arcpy.XYTableToPoint_management(in_table, output, x_field, y_field, z_field, coordinate_system)
def XYCoordToPoint(x, y, name, path='/Data/Generated/Point.csv'): with open(path, "w") as f: string = str(x) + "," + str(y) f.write("x,y\n" + string) arcpy.XYTableToPoint_management( path, name, "x", "y", coordinate_system=arcpy.SpatialReference("British National Grid"))
#cursor = arcpy.da.UpdateCursor(plottab, [longitude,latitude]) #for row in cursor: # lon = row[0] # lat = row[1] # newsr = transform(Proj(init='epsg:3857'), Proj(init='epsg:4326'), lon, lat) # newlon = newsr[0] # newlat = newsr[1] # newrow = [newlon, newlat] # cursor.updateRow(newrow) #del cursor # assume WGS 1984 arcpy.XYTableToPoint_management(incsv,plots, x_field = longitude, y_field = latitude, coordinate_system = sr) plots_proj = 'plots_proj' transformation = 'WGS_1984_(ITRF00)_To_NAD_1983' #going from sr to pr coordinate system arcpy.Project_management(plots, plots_proj, pr, transformation, sr) # # Section 2 : Accessing APIS and Getting Explanatory Data # # Download a Layer From ArcGIS hub
# 現在の日時でフォルダを作成 os.makedirs(workPath + r"\output\{0}".format(dateStr)) ###################################### # CSV ファイルを読込む # ポイント フィーチャ クラスを作る ###################################### # ジオプロセシングツールに必要なパラメータの作成 csv_table = workPath + r"\current.csv" out_csv_feature_class = "csv{0}".format(dateStr) x_field = "X" y_field = "Y" current_csv_feature_class = "current" # ジオプロセシングツールの実行 arcpy.XYTableToPoint_management(csv_table, out_csv_feature_class, x_field, y_field) arcpy.DeleteFeatures_management(current_csv_feature_class) arcpy.Append_management(out_csv_feature_class, current_csv_feature_class, "NO_TEST") ###################################### # 各駅ごとの放置車両数を集計する ###################################### # フィーチャクラス (curent) に対してカーソルを定義 cursor = arcpy.UpdateCursor("current") # 23 区ごとに放置車両の合計値を算出 for row in cursor: row.setValue( "放置車両_合計", row.getValue("放置台数_自転車") + row.getValue("放置台数_原付") + row.getValue("放置台数_自二"))
Clumped_Clusters = r"C:\GEOM67_Program\GroupProject2\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model.gdb\Clumped_Clusters" SQL_Expression__5_ = "CLUSTER_ID = -1" Dispersed_Input = r"C:\GEOM67_Program\GroupProject2\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model.gdb\Dispersed_Input" String__Multi_scale__OPTICS__Clustering = "OPTICS" Dispersed_Clusters = r"C:\GEOM67_Program\GroupProject2\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model.gdb\Dispersed_Clusters" SQL_Expression__3_ = "CLUSTER_ID = -1" Random_Points = r"C:\GEOM67_Program\GroupProject2\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model\Fire_Cluster_Analysis_Model.gdb\Random_Points" # Process: XY Table To Point tempEnvironment0 = arcpy.env.outputCoordinateSystem arcpy.env.outputCoordinateSystem = "Coordinate System" arcpy.XYTableToPoint_management( in_table=Input_CSV_Table, out_feature_class=Fire_Points_From_Table, x_field="longitude", y_field="latitude", z_field="", coordinate_system= "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision" ) arcpy.env.outputCoordinateSystem = tempEnvironment0 # Process: Select (2) arcpy.Select_analysis(in_features=Fire_Points_From_Table, out_feature_class=Fire_Points_TimeFrame, where_clause=Time_Range) # Process: Select arcpy.Select_analysis(in_features=Boundary_Shapefile, out_feature_class=Area_Selection, where_clause=Location)
stStatsJson = stStatResponse.json() statusData = stStatsJson['data'] stStatuses = statusData['stations'] with open(tableLocation, 'w+') as file: file.write("Station ID" + seperator + "Navn" + seperator + "Adresse" + seperator + "Latitude" + seperator + "Longitude" + seperator + "Plasser" + seperator + "Har ledige sykler" + seperator) # TODO Kombinere statusene til stasjonene for å gi data på hvor mange sykler som er ledig f.eks. # TODO Finn en måte å bruke ID på for å kombinere dataene # for stationStatus in stStatuses: for station in stations: with open(tableLocation, 'a+') as file: file.write("\n" + station['station_id'] + seperator + station['name'] + seperator + station['address'] + seperator + str(station['lat']) + seperator + str(station['lon']) + seperator + str(station['capacity']) + seperator) arcpy.XYTableToPoint_management(tableLocation, featureClass, 'Longitude', 'Latitude') arcpy.AddMessage("Processing finished. Bysykkelstasjoner is complete.") else: arcpy.AddMessage( "There was en error connecting to the API.\nErrocode as follows: " + str(stInfoResponse.status_code))