1

I need to choose points from a shapefile, which are positioned on raster cells with 0 degree slope. Creating a slope raster from DME is not a problem, but I don't know how to write a script that chooses points positioned only on zero slope.

I don't know if use GDAL or it's possible over ArcPy or anything.

1
  • 2
    Please edit the question to specify whether a script is required. ArcPy could certainly do this, and GDAL might as well, but these are two different questions (GIS SE limits each Question to one question). Using whatever tool, you just need to classify the raster as zero slope or NODATA, then convert to polygon for theme-on-theme selection. – Vince Dec 13 '15 at 16:30
2

This can be accomplished in two steps using the following workflow, assuming you have the ArcGIS Spatial Analyst license:

  1. Extract Multi Values to Points (Spatial Analyst)
  2. Select (Analysis)

Step 1 adds the raster value (i.e. slope) at each point to the attributes. Step 2 selects and creates a new feature class of all points that meet your condition (i.e. where slope == 0). Note keep in mind this will alter your original point feature class, so make sure to use a copy.

In Python, this would look something like:

import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

points = r'C:\path\to\your\point.shp' # This should be a copy
raster = r'C:\path\to\your\slope_raster.tif'
outshp = r'C:\path\to\your\output_shp.shp'

# Execute ExtractValuesToPoints
ExtractMultiValuesToPoints(points, raster, "BILINEAR")

#Select points that meet your condition
where_clause = '"slope" = 0'
arcpy.Select_analysis(points, outshp, where_clause)
6
  • thanks you , but now i have this problem – David Dec 13 '15 at 23:10
  • Thank you for a help, but now i have this problem "Message File Name Line Position Traceback <module> D:\School\APU\projekt\script.py 49 Select D:\Apps\ArcGIS\Desktop10.3\ArcPy\arcpy\analysis.py 84 "ExecuteError: ERROR 000358: Invalid expression ""SLOPE"" = '0' Failed to execute (Select).#Slope inRaster = "dem" Units = "DEGREE" zFactor = 1 outSlope = Slope(inRaster, Units, zFactor) outSlope.save("vysledek/slope.tif") this is how i creating slope raster, maybe this is a problem – David Dec 13 '15 at 23:13
  • It looks like a bad SQL expression. I suspect that you need to replace "SLOPE" with whichever value is in your point shapfile attribute table containing the slope values. – Aaron Dec 13 '15 at 23:21
  • I changed it from "SLOPE" to "slope" ...exactly like is in my point shapefile but still the same result – David Dec 13 '15 at 23:52
  • ok i have it, problem was in this..it should look like where_clause = '"slope" = 0' – David Dec 14 '15 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.