A new tool was added to ArcGIS 10.3 to convert a page in a PDF to TIFF. This is especially useful for the asset management work I do, as I often get pdf drawings or maps which need to be georeferenced. I created a function to wrap around the ArcGIS one to enable the conversion of more than one page in the pdf at a time.
By default, the function will only convert the first page. Specifying a start and/or end page will override the defaults. Link to the code is here.
*Before I get into today’s script, I’ve noticed that the embedded gists do not appear on mobile devices when accessing the feed for this blog via Feedly or some other RSS reader. The post needs to be opened in a web browser to view the code. I’ll also be including a link to it at the end of the post.
When I create feature classes for asset management data manually instead of automatically, I always make sure to name them consistently. However, I rarely change the feature class alias manually. This means that when I need to pull all the layers into a map to create a kml, I need to rename each layer.
Which is why I turn to Python instead.
Of course, the way the name gets split will change depending on the current format of the names. In this instance, the part of the name that I needed occurred after the first full stop, and contained underscores which needed to be replaced by spaces. I then used a regular expression to insert spaces between
Link to the code is here.
I needed to create random points inside polygons for some testing I needed to do. Since I only had a Standard Licence available (and therefore no access to the Create Random Points tool that I used to POST random points as ESRI JSON to a REST endpoint), I decided it was as good a time as any to write a tool in Python.
After creating an
InsertCursor on the point feature class, I iterate over the polygon feature class using a
SearchCursor. In Line 25, a random number is chosen between 1 and 10 to determine the number of points that will be created for that feature. The extent of the current feature is stored in Line 26.
The actual points are created in Lines 30 – 34. For each point, a random floating point number within the polygon’s extent is chosen as the
y coordinates. A point feature is created using the coordinates to build the geometry, as well as the name of the polygon feature. The point feature is then inserted into the point feature class.
I have a table containing a description field and an integer field which has values along the line. I need to split each line according to the values in the table.
segmentAlongLine requires a start and end value for where the line needs to be cut. The end value is the current row’s measure value, while the start value is the previous row’s end value. After trying to move the cursor back and forth, I decided the best way to achieve this would be to simply store the row’s value in the start variable.
The script inserts the segments into an existing line feature class.