For this purpose, we convert the slackwater raster to a shapefile and calculate the surface area of the shapefile with the following arcpy methods:Ĭonvert the raster to a shapefile with arcpy.RasterToPolygon_conversion() with arguments: Because slackwater is designated preferred habitat of some aquatic species, we are wondering now how much slackwater area the numerical model predicts in the simulated river section. Such shallow and slow-flow regions are called slackwater (according to Wyrick and Pasternack ). It uses an integer raster of all pixels where the flow depth and velocity are smaller than 1.4 m and 0.15 m/s, respectively. The following example features the conversion of a raster to a polygon shapefile. ![]() ![]() Rasters can be converted to polygon and other shapefile types (e.g., point). This is why this tutorial starts with the conversion of raster data to shapefiles along with the illustration of other functions such as calculating patch area and accessing shapefile attribute tables. At this stage, raster data (output of numerical models) must first be converted into shapefiles. In codes, the processing of shapefiles only becomes important in the analysis of the output of numerical models (e.g., to classify morphological unit features, exactly calculate patch areas, or automatically place reinforcements in construction plans). Examples can be found in the BASEMENT tutorial (explore the creation of elevation point, boundary polygon, and breakline polyline shapefiles). In hydraulic engineering, however, we usually create (draw) shapefiles manually either directly with ArcGIS or its open-source competitor QGIS to delineate, for example, particular flow regions. No wonder, arcpy is good at handling this vector data format. The geospatial shapefile vector format is an Esri invention. To install more packages follow the descriptions provided by Esri.Īn open access alternative to arcpy’s CellStatistics is the ref rasterstats library (usage: rasterstats.zonal_stats(zone, raster_file_name, stats=)). Finalize the creation of the new environment with a click on Create. Moreover, find the conda.exe or python.exe in the above directories and define it in the field Conda executable. It may occur that it is not necessary to add the propy directory. If ArcGIS Pro was installed for individual users, use: %LOCALAPPDATA%\Programs\ArcGIS\Pro\bin\Python\Scripts\propy If ArcGIS Pro was globally installed by the system administrator, use: %PROGRAMFILES%\ArcGIS\Pro\bin\Python\Scripts\propy To create a new conda environment in P圜harm with ESRI’s conda environment, the Location must be defined differently (see the original screenshot): The Python installation section explains how to set up P圜harm IDE with a conda environment. Use arcpy with External IDEs # Setup Interpreter # There are many more methods implemented in arcpy and only the fundamentals are explained here. This page shows the basics for manipulating raster and shapefile data in Python with arcpy. Thanks to arcpy, such popular ArcGIS tools can be embedded in Python scripts, thus enabling workflows to be automated and efficiency to be significantly increased. Among the popular functionalities of ArcGIS software are Raster Calculator, Shapefile Feature manager, or tools for statistical analysis of geo-databases. In this case, a company (or research institution) covers the license fees and it is equally likely that a Windows operating system is used for similar reasons. ![]() If you are working for a company with engineering services, the company likely uses ArcGIS because of its popularity and commercial support service. Why can working with arcpy in Python still be a powerful tool even though there are many license and platform restrictions? At the time of writing this introduction ArcGIS Pro and arcpy cannot be used on Linux or macOS platforms. ![]()
0 Comments
Leave a Reply. |