Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. from __future__ import print_function
  2. import arcrest
  3. import json
  4. import csv
  5. if __name__ == "__main__":
  6. username = "uid"
  7. password = "pwd"
  8. portalId = "id"
  9. url = "http://www.arcgis.com/"
  10. thumbnail_url = ""
  11. with open('TILES.csv') as csvfile:
  12. inputFile = csv.DictReader(csvfile)
  13. x = 0 # counter to display file count
  14. for row in inputFile:
  15. if x == 0:
  16. map_json = {
  17. "operationalLayers": [
  18. {
  19. "templateUrl": "https://{subDomain}.tiles.mapbox.com/v4/abc.GRSM_"+row['ID']+"_pink/{level}/{col}/{row}.png?access_token=pk.secret",
  20. "id": "GRSM_SPECIES_OBSERVATIONS_MAXENT_5733",
  21. "type": "WebTiledLayer",
  22. "layerType": "WebTiledLayer",
  23. "title": row['Species']+" Prediction",
  24. "copyright": "GRSM",
  25. "fullExtent": {
  26. "xmin": -20037508.342787,
  27. "ymin": -20037508.34278,
  28. "xmax": 20037508.34278,
  29. "ymax": 20037508.342787,
  30. "spatialReference": {
  31. "wkid": 102100
  32. }
  33. },
  34. "subDomains": [
  35. "a",
  36. "b",
  37. "c",
  38. "d"
  39. ],
  40. "visibility": True,
  41. "opacity": 1
  42. }
  43. ],
  44. "baseMap": {
  45. "baseMapLayers": [
  46. {
  47. "id": "defaultBasemap",
  48. "layerType": "ArcGISTiledMapServiceLayer",
  49. "opacity": 1,
  50. "visibility": True,
  51. "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
  52. }
  53. ],
  54. "title": "Topographic"
  55. },
  56. "spatialReference": {
  57. "wkid": 102100,
  58. "latestWkid": 3857
  59. },
  60. "version": "2.0"
  61. }
  62. securityHandler = arcrest.AGOLTokenSecurityHandler(username,
  63. password)
  64. # Create the administration connection
  65. #
  66. admin = arcrest.manageorg.Administration(url, securityHandler)
  67. # Access the content properties to add the item
  68. #
  69. content = admin.content
  70. # Get the user #
  71. user = content.users.user()
  72. # Provide the item parameters
  73. #
  74. itemParams = arcrest.manageorg.ItemParameter()
  75. itemParams.title = "GRSM_"+row['Species']
  76. itemParams.thumbnailurl = ""
  77. itemParams.type = "Web Map"
  78. itemParams.snippet = "Maxent Output: "+row['Species']
  79. itemParams.licenseInfo = "License"
  80. itemParams.accessInformation = "Credits"
  81. itemParams.tags = "Maxent"+row['Species']
  82. itemParams.description = "This map depicts the tiled output of a Maxent model depicting the probability of occurrence of "+row['Species']+". An in-line legend is not available for this map. "
  83. itemParams.extent = "-84.1076,35.2814,-82.9795, 35.8366"
  84.  
  85. # Add the Web Map
  86. #
  87. print (user.addItem(itemParameters=itemParams,
  88. overwrite=True,
  89. text=json.dumps(row)))
  90. x = x + 1
  91.  
  92. Species,ID
  93. Abacion_magnum,0000166
  94. Abaeis_nicippe,0000169
  95. Abagrotis_alternata,0000172
  96. Abies_fraseri,0000214
  97. Ablabesmyia_mallochi,0000223
  98. Abrostola_ovalis,0000232
  99. Acalypha_rhomboidea,0000253
  100. Acanthostigma_filiforme,0000296
  101. Acanthostigma_minutum,0000297
  102. Acanthostigma_multiseptatum,0000298
  103. Acentrella_ampla,0000314
  104. Acer_negundo,0000330
  105. Acer_pensylvanicum,0000333
  106. Acer_rubrum_v_rubrum,0000337
  107. Acer_rubrum_v_trilobum,0000338
  108. Acer_saccharum,0000341
  109. Acer_spicatum,0000343
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement