FeatureSet

Resumen

FeatureSet objects are a lightweight representation of a feature class. They are a special data element that contains not only schema, but also the data. The FeatureSet object is also how feature data is sent and received from the server.

Debate

Nota:

If you're loading a feature class into a new FeatureSet and modifying the FeatureSet with a geoprocessing tool that modifies the input such as Calculate Field or a function such as UpdateCursor, the original feature class will also be modified.

Sintaxis

 FeatureSet  ({table})
ParámetroExplicaciónTipo de datos
table

Feature data to be loaded into the FeatureSet object.

String

Propiedades

PropiedadExplicaciónTipo de datos
JSON
(Sólo lectura)

Returns an Esri JSON representation of the geometry as a string.

Sugerencia:

The returned string can be converted to a dictionary using the Python json.loads function.

String

Descripción general del método

MétodoExplicación
load (table_path, {where_clause}, {time_filter}, {renderer}, {is_renderer})

Import from a table.

save (table_path)

Export to a table.

Métodos

load (table_path, {where_clause}, {time_filter}, {renderer}, {is_renderer})
ParámetroExplicaciónTipo de datos
table_path

The table to be imported.

The input can be a catalog path to a feature class, a URL to a hosted feature layer, or a URL JSON with the syntax {"url":"<url>", "token":"<token", "referer":"<referer>"} to load data from external sources that require an access token.

String
where_clause

An SQL expression used to select a subset of records.

For more information on SQL syntax, see SQL reference for query expressions used in ArcGIS.

(El valor predeterminado es None)

String
time_filter

The time instant or the time extent to query. The time filter can only be applied to hosted feature layers, and the layer must be time-enabled.

A time instant should be formatted as a string, for example, "1199145600000" ((1 Jan 2008 00:00:00 GMT). A time extent should be a comma-delimited string, for example: "1199145600000, 1230768000000" (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT).

A null value specified for the start time or the end time will represent infinity for the start or the end time, respectively, for example: "null, 1230768000000".

(El valor predeterminado es None)

String
renderer

The output FeatureSet symbology can be set using a string, or dictionary representation of either a JSON renderer or a JSON Definition object.

Learn more about JSON renderers and JSON definition objects.

(El valor predeterminado es None)

String
is_renderer

Specifies the type of the value used with the renderer argument. Set to True if the value is a renderer object, and False if the value is a definition.

(El valor predeterminado es None)

Boolean

The optional parameters are positional only; they cannot be passed by keyword. For example, if the intent is to only specify symbology, the optional arguments where_clause and time_filter must be skipped using None.

save (table_path)
ParámetroExplicaciónTipo de datos
table_path

The output table to be created.

String

Muestra de código

FeatureSet example 1

Load data into a FeatureSet and insert into a feature class.

import arcpy

arcpy.env.overwriteOutput = True

arcpy.ImportToolbox("http://flame7/arcgis/services;BufferByVal",
                    "servertools")

# List of coordinates
coordinates = [[-117.196717216, 34.046944853],
               [-117.186226483, 34.046498438],
               [-117.179530271, 34.038016569],
               [-117.187454122, 34.039132605],
               [-117.177744614, 34.056765964],
               [-117.156205131, 34.064466609],
               [-117.145491191, 34.068261129],
               [-117.170825195, 34.073618099],
               [-117.186784501, 34.068149525],
               [-117.158325598, 34.03489167]]

# Create an in_memory feature class to initially contain the coordinate pairs
feature_class = arcpy.CreateFeatureclass_management(
    "in_memory", "tempfc", "POINT")[0]

# Open an insert cursor
with arcpy.da.InsertCursor(feature_class, ["SHAPE@XY"]) as cursor:
    # Iterate through list of coordinates and add to cursor
    for (x, y) in coordinates:
        cursor.insertRow([(x, y)])

# Create a FeatureSet object and load in_memory feature class
feature_set = arcpy.FeatureSet()
feature_set.load(feature_class)

results = arcpy.BufferPoints_servertools(feature_set)
FeatureSet example 2

Load a subset of data from ArcGIS Living Atlas of the World into a FeatureSet and set the symbology.

import arcpy

# Set data
in_data = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_States_Generalized/FeatureServer/0"
query = "STATE_NAME = 'California'"
renderer = '''{
    "renderer": {
        "type": "simple",
        "symbol": {
            "type": "esriSFS",
            "style": "esriSFSSolid",
            "color": [
                255,
                0,
                0,
                255
            ],
            "outline": {
                "type": "esriSLS",
                "style": "esriSLSSolid",
                "color": [
                    110,
                    110,
                    110,
                    255
                ],
                "width": 2
            }
        },
        "label": "",
        "description": "",
        "rotationType": "geographic",
        "rotationExpression": ""
    }
}'''

# Create empty FeatureSet
feature_set = arcpy.FeatureSet()

# Load data into FeatureSet with query
feature_set.load(in_data, query, None, renderer, True)

Temas relacionados