0

I have a shapefile of lines containing an amount n of elements. I exported these features and analyzed them with another program (Matlab), which provided me as an output a row vector of length n containing only 1s and 0s. I would like to read this vector in ArcMap, and highlight somehow the elements whose Objtect ID is equal to a vector elements equal to 1.

The reason why I want to highlight them is to export an image showing the chosen features.

I still do not have a code since I do not know if what I want to do can actually be done, nevertheless, here there is a non-python, Matlab-like code that hopefully will better describe what I would like to do:

load Portfolio.mat %this is my n-vector of 1s and 0s
for i=1:length(Portfolio)
    if Portfolio(i) ==1
        highlight (feature(ObjectID == i)) %this is the function that I do not know if it exists
    end
end

Can this be done? Is there a geoprocessing tool able to do this or is it necessary to write a python script for this purpose?

1

You could create a Python Geoprocessing tool and use the arcpy.MakeFeatureLayer_management function (see http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/make-feature-layer.htm) to create a layer and then use the arcpy.SelectLayerByAttribute_management function (see http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/select-layer-by-attribute.htm) using the "ADD_TO_SELECTION" selection type.

This will select the data as well as highlight it on the map. Not the typical highlight function in ArcMap, but may suffice for your needs.

Also, in your pseudocode, you may not want to use the index of the vector and the OBJECTID as the reference. The OBJECTID field does not always have to start at 1. A better way would be to use a cursor to open the feature class (shapefile), increment an index for each row read, and use that index to reference the data in the Matlab file.

|improve this answer|||||
  • Thank you for your answer. Would it be possible to select the features directly from the original layer? I took a look on the Internet but I did not find any function "SelectFeaturebyAttribute" so I do not know if this exists or if I necessarely have to create a new layer before – Patapunfate Jun 22 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.