如何使用python在线在arcgis中使用经/纬度值从头开始创建和发布新的要素图层?

时间:2019-05-18 00:28:22

标签: python arcgis

我设法从头开始创建一个FeatureSet并将其添加到地图中,然后发布它。。。。。。在无法渲染的已发布Set中我缺少什么?

我试图发布CSV文件来获得积分。我需要的是一些要点之间的界线。因此,我创建了几条折线并将其添加到要素中,然后将其放置在地图的图层上。

然后,我同时发布了图层和地图。既不会在地图中渲染,也不会在添加为图层时出现。

from arcgis.gis import GIS 

gis = GIS("https://www.arcgis.com", "myusername", "mypasswd") 

import json
import arcgis.geometry as gm
import arcgis.features as features

line = {
  "paths" : [ 
             [[-97.0000,32.0000],[-98.0000,32.000],[-98.0000,31.0000],[-97.0000,31.00000]],
             [[-97.06326,32.759],[-97.06298,32.755]]],
  "spatialReference" : {"wkid" : 3857}
}
p1 = gm.Polyline(line) 

line = {
  "paths" : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],
             [[-97.06326,32.759],[-97.06298,32.755]]],
  "spatialReference" : {"wkid" : 3857}
}
p2 = gm.Polyline(line) 
# wkid could be 4326??
F1 = features.Feature(geometry=p1)
F2 = features.Feature(geometry=p2)

fc_prop = { 'title' : 'Random Square' , 'type': 'Feature Collection' } 
FL = features.FeatureLayer("my-url-to-existing-layer")
FSet = features.FeatureSet(features=[F1,F2] , geometry_type = 'Polyline')
map1 = gis.map('USA') 
map1.add_layer(FSet, { "renderer" : "ClassedSizeRenderer",  } )
ly = map1.layers[0]

item_properties = {
    "title": "This 3857 Aint Right",
    "tags" : "oil,gas,wells,roses", 
    "description" : "...from simple layer....", 
    "type": "Feature Collection",
    "typeKeywords": "Data, Feature Collection",
    }
# ly.layer.layers[0].layerDefinition.drawingInfo.renderer.symbol 
item_properties['text'] = json.dumps({'featureCollection': dict(ly.layer) })
item = gis.content.add(item_properties)
gis.content.share_items(item, everyone=True)
# Saves a map 
ip= { 'title': "another layer" , 'snippet': "added polygon", 'tags': "some,ting,wong" } 
map1.save(ip)
---

I get no errors from the calls - the FeatureLayer shows up in my GIS account but does not render. 

I have dumped the layer that I am publishing as a JSON object. 

---json
{
  "layers": [
    {
      "featureSet": {
        "geometryType": "Polyline",
        "features": [
          {
            "geometry": {
              "paths": [
                [
                  [
                    -97.0,
                    32.0
                  ],
                  [
                    -98.0,
                    32.0
                  ],
                  [
                    -98.0,
                    31.0
                  ],
                  [
                    -97.0,
                    31.0
                  ]
                ],
                [
                  [
                    -97.06326,
                    32.759
                  ],
                  [
                    -97.06298,
                    32.755
                  ]
                ]
              ],
              "spatialReference": {
                "wkid": 3857
              }
            },
            "attributes": {
              "OBJECTID": 1
            }
          },
          {
            "geometry": {
              "paths": [
                [
                  [
                    -97.06138,
                    32.837
                  ],
                  [
                    -97.06133,
                    32.836
                  ],
                  [
                    -97.06124,
                    32.834
                  ],
                  [
                    -97.06127,
                    32.832
                  ]
                ],
                [
                  [
                    -97.06326,
                    32.759
                  ],
                  [
                    -97.06298,
                    32.755
                  ]
                ]
              ],
              "spatialReference": {
                "wkid": 3857
              }
            },
            "attributes": {
              "OBJECTID": 2
            }
          }
        ]
      },
      "layerDefinition": {
        "geometryType": "Polyline",
        "fields": [
          {
            "name": "OBJECTID",
            "type": "esriFieldTypeOID",
            "alias": "OBJECTID",
            "sqlType": "sqlTypeOther"
          }
        ],
        "objectIdField": "OBJECTID",
        "type": "Feature Layer",
        "drawingInfo": {
          "renderer": {
            "type": "simple",
            "symbol": "circle"
          }
        }
      }
    }
  ]
}

---

0 个答案:

没有答案