Guest User

Untitled

a guest
Feb 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. # make custom button to search Parcels by Parcel Number
  2. # and zoom to selected parcel
  3. mxd = arcpy.mapping.MapDocument("CURRENT")
  4. df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
  5. input_PIN = raw_input('Enter your value :')
  6. sql_exp = """"PIN" = '""" + input_PIN + "'"
  7. Llayer = arcpy.mapping.Layer(r"C:commonGeneParcels.shp")
  8. Llayer.definitionQuery = sql_exp
  9. arcpy.mapping.AddLayer(df, Llayer)
  10. dfNEWextent = Llayer.getExtent()
  11. df.extent = dfNEWextent
  12.  
  13. PYQGIS Code:
  14.  
  15. from qgis.core import *
  16. from PyQt4.QtCore import *
  17. from PyQt4.QtGui import QInputDialog
  18. QgsApplication.setPrefixPath("C:Program FilesQGIS Pisabin", True)
  19. QgsApplication.initQgis()
  20. cLayer = iface.mapCanvas().currentLayer()
  21. input_PIN = QInputDialog.getText(None,'Parcel Number','Enter PIN:')
  22. expr = QgsExpression(""""PIN" = '""" + input_PIN + "'")
  23. it = cLayer.getFeatures( QgsFeatureRequest( expr )
  24. ids = [i.id() for i in it]
  25. cLayer.setSelectedFeatures( ids )
  26. iface.mapCanvas().zoomToSelected()
Add Comment
Please, Sign In to add comment