-
-
Save NathanW2/4de348da41113dbeba03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapselection(self): | |
def add_city(feature): | |
""" | |
Add a city to the output list | |
""" | |
nearCity = feature['name'] | |
state = feature['state'] | |
state_and_cities = "{},{}".format(nearCity, state) | |
lsNearCities.append(state_and_cities) | |
filePath = self.dlg.fileNameEdit.text() | |
if not filePath: | |
QMessageBox.warning(self.dlg, "File Name","Give it a file name and try again") | |
return | |
lsNearCities = [] | |
layer = QgsMapLayerRegistry.instance().mapLayersByName('us_cities')[0] | |
selfeature = layer.selectedFeatures() | |
distance = self.dlg.DistancelineEdit.text() | |
dist = float(distance) * (1609.344) | |
if distance and dist != 0: | |
for feature in selfeature: | |
mbuf = feature.geometry().buffer(dist, 2) | |
iterFeat = layer.getFeatures() | |
for f in iterFeat: | |
geom2 = f.geometry() | |
if geom2.within(mbuf): | |
add_city(f) | |
else: | |
for feature in selfeature: | |
add_city(feature) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment