Selecting Attribute tool for a layer Announcing the arrival of Valued Associate #679: Cesar...

Is it accepted to use working hours to read general interest books?

Why does Java have support for time zone offsets with seconds precision?

Test if all elements of a Foldable are the same

Is there a possibility to generate a list dynamically in Latex?

How was Lagrange appointed professor of mathematics so early?

Will I lose my paid in full property

"Working on a knee"

Is Bran literally the world's memory?

What helicopter has the most rotor blades?

What happened to Viserion in Season 7?

Is there a way to fake a method response using Mock or Stubs?

Writing a T-SQL stored procedure to receive 4 numbers and insert them into a table

Could a cockatrice have parasitic embryos?

Determinant of a matrix with 2 equal rows

Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?

Why did Europeans not widely domesticate foxes?

How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?

My admission is revoked after accepting the admission offer

What is the numbering system used for the DSN dishes?

Is it appropriate to mention a relatable company blog post when you're asked about the company?

Coin Game with infinite paradox

Like totally amazing interchangeable sister outfit accessory swapping or whatever

Marquee sign letters

How would you suggest I follow up with coworkers about our deadline that's today?



Selecting Attribute tool for a layer



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)selecting by attribute and specific value replaceAdd layer to open mxd using ArcObjects from outside the map document crashes ArcMapAdd feature layer to display with in a script tool for desktop mapping 'App'Where clause problems when all parts are user input variablesOpening/closing an MXD that uses “production mapping” for dynamic tables in PythonUsing Google API within Python and applying to ArcMap?Selecting objects from a feature layer by attribute using OR?Cannot find results of MakeFeatureLayer, cannot use SelectFeatureByAttributeTrying to use layer saved as .lyr file with arcpy.mapping.Layer function results in error?Make a XY Event Layer into Copy Feature layer





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am trying to run the select attribute tool for a layer that I created. I can manually run the tool in ArcMap, but when I write the script the code fails after the copy feature tool was used. Not sure what I am doing wrong, I am using the ArcMap help section to get a general idea of the code that I needed.



I am new to python, so I appreciate any guidance anyone has:



#Import a CSV file that will show you what ASOS weather stations are in the state.
import arcpy
import os

#Lets you write over the shape file if needed
arcpy.env.overwriteOutput = True

arcpy.env.workspace = "C:\GEOG485\FinalProject"

#Latitude and Longitude Coordinates
xFieldName = 'LON'
yFieldName = 'LAT'

#Output folder
outFolder = "C:\GEOG485\FinalProject\Output"

#ASOS stations layer
eventLayer = "ASOS"
outPutlayer = "C:\GEOG485\FinalProject\FinalProject.gdb\CurrentStations"
stateLayer = "C:\GEOG485\FinalProject\FinalProject.gdb\State_ASOS"

#Spatial Reference
spatialRef = arcpy.SpatialReference(4326)

#CSV file that will be imported into ArcMap
csvFilePath = "C:\GEOG485\FinalProject\isd-history.csv"

#Select state of interest
targetState = 'NJ'

#Date of file last updated
targetEnd = '20190329'


try:
#import csv file using the xy event layer tool
arcpy.MakeXYEventLayer_management(csvFilePath, xFieldName, yFieldName, eventLayer, spatialRef)
print ("success1")

#Copy features from the XY Event Layer in order to asign Object ID's to the rows in the file
arcpy.CopyFeatures_management(eventLayer, outPutlayer)
print ("success2")

stateQuery = '"STATE" = ' + "'" + targetState + "'"
#Select Attribute management to narrow down the state of interest
arcpy.SelectLayerByAttribute_management(outPutlayer, "NEW_SELECTION", stateQuery)
print ("success4")

arcpy.SelectLayerByAttribute_management(outPutlayer, 'SUBSET_SELECTION', '"END" = ' + "'" + targetEnd + "'")
print ("success5")

arcpy.CopyFeatures_management(outPutlayer, stateLayer)

except:
print ("error2")

try:
mxd = arcpy.mapping.MapDocument("C:\GEOG485\FinalProject\basemap.mxd")
df = arcpy.mapping.ListDataFrame(mxd, "*")[0]
newLayer = arcpy.mapping.Layer(outPutlayer)
arcpy.mapping.Layer(df, newLayer, "Bottom")
except:
print ("error4")









share|improve this question





























    0















    I am trying to run the select attribute tool for a layer that I created. I can manually run the tool in ArcMap, but when I write the script the code fails after the copy feature tool was used. Not sure what I am doing wrong, I am using the ArcMap help section to get a general idea of the code that I needed.



    I am new to python, so I appreciate any guidance anyone has:



    #Import a CSV file that will show you what ASOS weather stations are in the state.
    import arcpy
    import os

    #Lets you write over the shape file if needed
    arcpy.env.overwriteOutput = True

    arcpy.env.workspace = "C:\GEOG485\FinalProject"

    #Latitude and Longitude Coordinates
    xFieldName = 'LON'
    yFieldName = 'LAT'

    #Output folder
    outFolder = "C:\GEOG485\FinalProject\Output"

    #ASOS stations layer
    eventLayer = "ASOS"
    outPutlayer = "C:\GEOG485\FinalProject\FinalProject.gdb\CurrentStations"
    stateLayer = "C:\GEOG485\FinalProject\FinalProject.gdb\State_ASOS"

    #Spatial Reference
    spatialRef = arcpy.SpatialReference(4326)

    #CSV file that will be imported into ArcMap
    csvFilePath = "C:\GEOG485\FinalProject\isd-history.csv"

    #Select state of interest
    targetState = 'NJ'

    #Date of file last updated
    targetEnd = '20190329'


    try:
    #import csv file using the xy event layer tool
    arcpy.MakeXYEventLayer_management(csvFilePath, xFieldName, yFieldName, eventLayer, spatialRef)
    print ("success1")

    #Copy features from the XY Event Layer in order to asign Object ID's to the rows in the file
    arcpy.CopyFeatures_management(eventLayer, outPutlayer)
    print ("success2")

    stateQuery = '"STATE" = ' + "'" + targetState + "'"
    #Select Attribute management to narrow down the state of interest
    arcpy.SelectLayerByAttribute_management(outPutlayer, "NEW_SELECTION", stateQuery)
    print ("success4")

    arcpy.SelectLayerByAttribute_management(outPutlayer, 'SUBSET_SELECTION', '"END" = ' + "'" + targetEnd + "'")
    print ("success5")

    arcpy.CopyFeatures_management(outPutlayer, stateLayer)

    except:
    print ("error2")

    try:
    mxd = arcpy.mapping.MapDocument("C:\GEOG485\FinalProject\basemap.mxd")
    df = arcpy.mapping.ListDataFrame(mxd, "*")[0]
    newLayer = arcpy.mapping.Layer(outPutlayer)
    arcpy.mapping.Layer(df, newLayer, "Bottom")
    except:
    print ("error4")









    share|improve this question

























      0












      0








      0








      I am trying to run the select attribute tool for a layer that I created. I can manually run the tool in ArcMap, but when I write the script the code fails after the copy feature tool was used. Not sure what I am doing wrong, I am using the ArcMap help section to get a general idea of the code that I needed.



      I am new to python, so I appreciate any guidance anyone has:



      #Import a CSV file that will show you what ASOS weather stations are in the state.
      import arcpy
      import os

      #Lets you write over the shape file if needed
      arcpy.env.overwriteOutput = True

      arcpy.env.workspace = "C:\GEOG485\FinalProject"

      #Latitude and Longitude Coordinates
      xFieldName = 'LON'
      yFieldName = 'LAT'

      #Output folder
      outFolder = "C:\GEOG485\FinalProject\Output"

      #ASOS stations layer
      eventLayer = "ASOS"
      outPutlayer = "C:\GEOG485\FinalProject\FinalProject.gdb\CurrentStations"
      stateLayer = "C:\GEOG485\FinalProject\FinalProject.gdb\State_ASOS"

      #Spatial Reference
      spatialRef = arcpy.SpatialReference(4326)

      #CSV file that will be imported into ArcMap
      csvFilePath = "C:\GEOG485\FinalProject\isd-history.csv"

      #Select state of interest
      targetState = 'NJ'

      #Date of file last updated
      targetEnd = '20190329'


      try:
      #import csv file using the xy event layer tool
      arcpy.MakeXYEventLayer_management(csvFilePath, xFieldName, yFieldName, eventLayer, spatialRef)
      print ("success1")

      #Copy features from the XY Event Layer in order to asign Object ID's to the rows in the file
      arcpy.CopyFeatures_management(eventLayer, outPutlayer)
      print ("success2")

      stateQuery = '"STATE" = ' + "'" + targetState + "'"
      #Select Attribute management to narrow down the state of interest
      arcpy.SelectLayerByAttribute_management(outPutlayer, "NEW_SELECTION", stateQuery)
      print ("success4")

      arcpy.SelectLayerByAttribute_management(outPutlayer, 'SUBSET_SELECTION', '"END" = ' + "'" + targetEnd + "'")
      print ("success5")

      arcpy.CopyFeatures_management(outPutlayer, stateLayer)

      except:
      print ("error2")

      try:
      mxd = arcpy.mapping.MapDocument("C:\GEOG485\FinalProject\basemap.mxd")
      df = arcpy.mapping.ListDataFrame(mxd, "*")[0]
      newLayer = arcpy.mapping.Layer(outPutlayer)
      arcpy.mapping.Layer(df, newLayer, "Bottom")
      except:
      print ("error4")









      share|improve this question














      I am trying to run the select attribute tool for a layer that I created. I can manually run the tool in ArcMap, but when I write the script the code fails after the copy feature tool was used. Not sure what I am doing wrong, I am using the ArcMap help section to get a general idea of the code that I needed.



      I am new to python, so I appreciate any guidance anyone has:



      #Import a CSV file that will show you what ASOS weather stations are in the state.
      import arcpy
      import os

      #Lets you write over the shape file if needed
      arcpy.env.overwriteOutput = True

      arcpy.env.workspace = "C:\GEOG485\FinalProject"

      #Latitude and Longitude Coordinates
      xFieldName = 'LON'
      yFieldName = 'LAT'

      #Output folder
      outFolder = "C:\GEOG485\FinalProject\Output"

      #ASOS stations layer
      eventLayer = "ASOS"
      outPutlayer = "C:\GEOG485\FinalProject\FinalProject.gdb\CurrentStations"
      stateLayer = "C:\GEOG485\FinalProject\FinalProject.gdb\State_ASOS"

      #Spatial Reference
      spatialRef = arcpy.SpatialReference(4326)

      #CSV file that will be imported into ArcMap
      csvFilePath = "C:\GEOG485\FinalProject\isd-history.csv"

      #Select state of interest
      targetState = 'NJ'

      #Date of file last updated
      targetEnd = '20190329'


      try:
      #import csv file using the xy event layer tool
      arcpy.MakeXYEventLayer_management(csvFilePath, xFieldName, yFieldName, eventLayer, spatialRef)
      print ("success1")

      #Copy features from the XY Event Layer in order to asign Object ID's to the rows in the file
      arcpy.CopyFeatures_management(eventLayer, outPutlayer)
      print ("success2")

      stateQuery = '"STATE" = ' + "'" + targetState + "'"
      #Select Attribute management to narrow down the state of interest
      arcpy.SelectLayerByAttribute_management(outPutlayer, "NEW_SELECTION", stateQuery)
      print ("success4")

      arcpy.SelectLayerByAttribute_management(outPutlayer, 'SUBSET_SELECTION', '"END" = ' + "'" + targetEnd + "'")
      print ("success5")

      arcpy.CopyFeatures_management(outPutlayer, stateLayer)

      except:
      print ("error2")

      try:
      mxd = arcpy.mapping.MapDocument("C:\GEOG485\FinalProject\basemap.mxd")
      df = arcpy.mapping.ListDataFrame(mxd, "*")[0]
      newLayer = arcpy.mapping.Layer(outPutlayer)
      arcpy.mapping.Layer(df, newLayer, "Bottom")
      except:
      print ("error4")






      python select-by-attribute feature-layer






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 14 mins ago









      WillWill

      204




      204






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f320655%2fselecting-attribute-tool-for-a-layer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f320655%2fselecting-attribute-tool-for-a-layer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

          Meter-Bus Содержание Параметры шины | Стандартизация |...