Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # make custom button to search Parcels by Parcel Number
- # and zoom to selected parcel
- mxd = arcpy.mapping.MapDocument("CURRENT")
- df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
- input_PIN = raw_input('Enter your value :')
- sql_exp = """"PIN" = '""" + input_PIN + "'"
- Llayer = arcpy.mapping.Layer(r"C:commonGeneParcels.shp")
- Llayer.definitionQuery = sql_exp
- arcpy.mapping.AddLayer(df, Llayer)
- dfNEWextent = Llayer.getExtent()
- df.extent = dfNEWextent
- PYQGIS Code:
- from qgis.core import *
- from PyQt4.QtCore import *
- from PyQt4.QtGui import QInputDialog
- QgsApplication.setPrefixPath("C:Program FilesQGIS Pisabin", True)
- QgsApplication.initQgis()
- cLayer = iface.mapCanvas().currentLayer()
- input_PIN = QInputDialog.getText(None,'Parcel Number','Enter PIN:')
- expr = QgsExpression(""""PIN" = '""" + input_PIN + "'")
- it = cLayer.getFeatures( QgsFeatureRequest( expr )
- ids = [i.id() for i in it]
- cLayer.setSelectedFeatures( ids )
- iface.mapCanvas().zoomToSelected()
Add Comment
Please, Sign In to add comment