Created
September 25, 2016 17:49
-
-
Save jmtaysom/f4ec4d4c441edd821e7e70051d8f72db 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
from __future__ import print_function | |
import arcpy | |
arcpy.env.overwriteOutput = True | |
arcpy.env.workspace = r"D:\Masters\GEOG_485\Lesson_3\Project3" | |
osmPoints = r"OSMpoints.shp" | |
centralAmerica = r"CentralAmerica.shp" | |
amenities = ['school', 'hospital', 'place_of_worship'] | |
country = 'El Salvador' | |
arcpy.MakeFeatureLayer_management(centralAmerica, "centralAmericaLayer") | |
for amenity in amenities: | |
try: | |
amenitySelectionClause = '"amenity" = ' + "'" + amenity + "'" | |
arcpy.MakeFeatureLayer_management(osmPoints, "osmPointsLayer", amenitySelectionClause) | |
# Here I'm trying to make a SBA and a SBL so I can copy the layer to a new FC. Nothing is working | |
arcpy.SelectLayerByAttribute_management('centralAmericaLayer', 'NEW_SELECTION', "\"NAME\" = 'El Salvador'") | |
print("SBA made") | |
arcpy.SelectLayerByLocation_management("osmPointsLayer", "CONTAINED_BY", "centralAmericaLayer") | |
print("SBL Made") | |
arcpy.CopyFeatures_management("osmPointsLayer", (amenity + "_outputName")) | |
print(amenity + "_outputName") | |
except Exception as e: | |
print(e) | |
print(arcpy.GetMessages(0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment