Skip navigation
All People > Dan_Patterson > Py... blog > 2019 > June
2019

A dministrator privileges … or you know the IT peeps … or you have created a cloned environment.

Pick one.

 

My installation path :     C:\arc_pro   ….. everything beyond this point is the same

Your installation path :   C:\...........    ….. got it?

 

Table of contents

 

Download and install tips

 

1  Follow the help topics:

ArcGIS Pro 2.4 system requirements—ArcGIS Pro | ArcGIS Desktop 

Download, install, and authorize—ArcGIS Pro | ArcGIS Desktop 

 

2  Go back to step 1.

Really, it is good and should be read, especially the part about your computer being able to run the software

 

3  My Esri, My Organization, Downloads

If it is there, it will look like the following:

 

 

4  Installation steps for retentives

Now, don't hit the Run option!  It is tempting, but there is Save and Save As.  Save As will be used.

To prepare for this, you should have done the following (not!, I am guessing)

  •  Make a folder to download your software ....
    • C:\users\you\whatever\downloads ... is no good, just because
    • C:\Computer\ArcGISPro_24 is good... simple, obvious and you own it
    • Download the *.exe to that folder using Save As
  • Right-click on the *.exe file and run it as administrator, specifying the above folder as the destination
  • Do the same for the *.msi file and you will automagically get a bunch of stuff in that folder AFTER the installation is complete... just follow that, but your folder should look like the following

Where step 1 is the main installation folder you created and downloaded the *.exe (2), when you run the *.exe, you will get the folder in step 3, and run the *.msi and you get the rest of the stuff.

 

Why do I do this? 

Because if things go really really bad, you will know where the ArcGISPro.msi file is, so when you have to do a complete uninstall, you can reinstall within a minute. 

Simple... no remembering or letting Microsoft Parent decide where things should go

 

What I did next

I do the conda thing... some legacy but relevant reading

ArcGIS Pro 2... Creating Desktop Shortcuts 

Spyder.... for coding with Python 

ArcGIS PRO  .... your conda environments and script editor 

 

Crank up conda through whatever means to run ...proenv.bat which sets everything up.  What is show below is what happens when I created a shortcut (Dolly) and messed around with the python ide so it isn't as dark and gloomy as yours will be.

 

I needed the following to do the programming I need and I did it in the following order.

 

1  Update numpy

(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3> conda update numpy

 

2 Downgrade sphinx to 1.8.5  (needed IF you document your scripts, otherwise the documentation will look horrible)

(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3> conda install sphinx==1.8.5

 

3  installed sphinx_rtd_theme   Getting Started with Sphinx — Read the Docs 3.5.3 documentation 

    You can skip this step if you don't do documentation or produce reports, or use Markdown or reStructured Text (or know what I am talking about )

(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3>conda install sphinx_rtd_theme --no-pin

 

4  Install spyder

(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3>conda install spyder

 

Tips

Never, never install without doing a test run first!

(arcgispro-py3) ….snip …. >conda install some_package --dry-run 

 

Then examine what it is going to do.  Sometimes, nothing 'bad' will happen, but you should at least make a copy what you are about to install.  If things go bad, you can roll back through the 'revisions' to a previous state.

 

Revision History from this install
(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3>conda list --revisions
2019-06-27 20:36:30  (rev 0)  Fresh install of ArcGIS Pro 2.4
    +arcgis-1.6.1 (esri)
    +arcgispro-2.4 (esri)
    ... huge snip ....
    +zeromq-4.3.1
    +zlib-1.2.11

2019-06-27 20:40:06  (rev 1)    The numpy upgrade
     ca-certificates  {2019.1.23 -> 2019.5.15}
     certifi  {2019.3.9 -> 2019.6.16}
     cffi  {1.12.2 -> 1.12.3}
     .... snip ...              
     numpy  {1.16.2 -> 1.16.4}
     numpy-base  {1.16.2 -> 1.16.4}
     .... snip .... 
    +pywin32-223
    +zipp-0.5.1
2019-06-27 20:47:46  (rev 2)   And So On.
    +alabaster-0.7.12
 .... snip .... 
2019-06-27 22:07:03  (rev 4)  And finally
    +sphinx_rtd_theme-0.4.3

Now if anything goes wrong, (Assuming I want to go back to revision 1)

(arcgispro-py3) C:\arc_pro\bin\Python\envs\arcgispro-py3>conda install --revision 1  (change 1 to your revision)


A little conda in spyder anyone?

Good luck

F ree basic functionality.  

 

I use Free as both a verb and an adjective

The examples I will be providing should be Free(d) and should not require an Advanced or Standard License... they should be Free with a basic license.

 

 

Previously

 - Free Tools : Frequency and Statistics

 

Help topic

Feature Envelope to Polygon

 

Spatial containers

Spatial containers can be used as substitutes for the original spatial pattern.  These would include ...

  • the shape itself,
  • convex hull,
  • concave hull
  • minimum area bounding (or perimeter)
    • circle
    • ellipse
    • rectangle
  • extent poly* features

 

The last of these are axis-aligned shapes bounded by the coordinates of the minimum of the lower left corner to upper right corner, not of the existing coordinates, but by the L(eft), B(ottom), R(ight) and T(op)… LBRT. 

Normally containers only make sense if you are using projected coordinates or can perform geodesic densification. 

 

Output example

Pretty well sums it up. 

  • Specify the input featureclass (polygon, polyline or multipoint),
  • the output type (polygon or polyline) and
  • the output featureclass.

The conversion uses the numpy based Geo class that I describe in the 8 part series on geometry. 

 

The conversion also handles shapes that contain curves, for simple geometry.  To do this, you will find that circles and ellipses or sliced sphericals contain 2 points... the identical start and end and no other points.  At least in a file geodatabase.  The quick solution is to densify the arc based on the ANGLE option in arcpy.densify.  I choose between 1, 2 or 5 degree densification depending on how fine I want the resultant n-gon to reflect the original  curve.

 

I could add the original attributes to the result (either within the toolset or after) or I could also 

Add Geometry Attributes ...

The full call to the tool, or the equivalent bits that I need.

A spatial or attribute join would be another alternative if you need attributes as well.

 

If you have a preference let me know.

The script is embedded for now.  I will release the script and final version when I have addressed all issues.

 

 

WARNING

I have code that checks the validity of the file paths.  If you input or output paths contain spaces or other flotsam, then the tool will not produce any results.  Why?  Too many questions where file paths are the problem.  I won't 'enable' the current practice

F ree basic functionality.  

 

I use Free as both a verb and an adjective

The examples I will be providing should be Free(d) and should not require an Advanced or Standard License... they should be Free with a basic license.

History

Frequency .... the help topic

It started a long time ago with Split Layer By Attributes.

Advanced license for so long, when really... the means to provide the analysis were already there.  Eventually, it was Free(d).

 

So this will be a series on how to perform functionality using the tools that are already provided for you within ArcGIS Pro and supplemental Python Packages which are already installed.

 

Maybe some educators out there will take application development directed towards analysis  as a serious area of GIS.

 

Tools to demonstrate

This blog series will NOT be about making maps or stuff related to expedite map making.  So if you want to develop tools for map making, then look elsewhere. 

I will begin with tools in the Analysis and Data Management Tools, for example:

 

  • Analysis Tools 
    •  Thiessen PolygonsThiessen Polygons in ArcGIS Pro  (Actually, I have done several incarnations of spatial triangulation and allocation already... nobody notices...)
  •  Data Management Tools
    •  Frequency … Frequency tool  (Ditto, One exists on the code sharing site but this is a beefed up version)

 

Example of Frequency and Statistics

If you had 4 counties with 4 towns of various size classes and you were interested in studying age dynamics versus population size, you might want to start with that basic premise.

  • Classify/group/categorize the towns by population size
  • Produce a unique classification scheme or use 2 or more existing fields to group your data for counting (aka, frequency).
  • Now, that the data are grouped, you can now determine some basic statistics for those classes.

 

Output example

See the table as an example...  A table is as good as a map and you don't get distracted by all those colors.

 

 

So, row 1, County A, Town_class A_.... 1195 people, some stats... Age_min will not be below 18... pretend, survey privacy.

 

A little Chi-Square, perhaps a Moran's (if we wanted to map) and off you go.  

Sadly this is in an Advanced license.  The whole production of the classification scheme, the frequency determination and the sorting is basically 1 line of code.  The stats stuff? python and numpy.  Null values? handled with ease... besides you should never have nulls anyway.

 

Requirements

So download and try it out on your data.

I would be interested in use cases to see what might be added.

The only restrictions...

  • ArcGIS Pro 2.4+ (might work on lower versions, but I no longer have them, and these are free anyway)
  • Locally stored data in a file geodatabase, like gdb tables or featureclass tables
  • If you have excel or csv files... do the work and make them gdb tables (there are tools for that, check ArcToolbox or my blog)
  • I embedded the script into the toolbox, let me know if it doesn't work embedded.  When I finish with suggestions for additions, I will Free the script so you can make your own modifications or additions

 

Have fun.

 

Up Next

Extent to Polygons  Converting feature extent(s) to polygons is a relatively easy task 

Featureclass Properties

 

  • Feature class info
  • Field info
  • Geometry info
  • Geometry decomposition

 

The code... I will update here.

 

 

Information functions for featureclasses

A quick solution to obtain geometry information.  Other info can be added.

fc_info(in_fc, prn=True)

FeatureClass:
   C:/Arc_projects/CoordGeom/CoordGeom.gdb/Shape2
shapeFieldName  OIDFieldName  shapeType spatialReference
Shape           OBJECTID      Polygon   NAD_1983_CSRS_MTM_9

Those pesky fields.  Don't want to open up ArcGIS Pro to find out?  Already got Spyder (or your Python IDE) open? Use this.

fld_info(in_fc, prn=True)

FeatureClass:
   C:/Arc_projects/CoordGeom/CoordGeom.gdb/Shape2
Name          Type         Length Nullable  Required 
OBJECTID      OID               4 False     True     
Shape         Geometry          0 True      True     
Shape_Length  Double            8 True      True     
Shape_Area    Double            8 True      True     
CENTROID_X    Double            8 True      False    
CENTROID_Y    Double            8 True      False    
INSIDE_X      Double            8 True      False    
INSIDE_Y      Double            8 True      False    

How many shapes? Are they all singlepart? How many points?  Which points connect to make what shape?

fc_geom_info(in_fc, SR=None, prn=True, start=0, num=10)

Featureclass:
    C:/Arc_projects/CoordGeom/CoordGeom.gdb/Shape2
   Shape    Parts   Points From_pnt   To_pnt
       1        2       21        0       21
       2        2       18       21       39
       3        1        4       39       43

Same as above... but where do the parts stop and start? Everyone loves stats! Right?

fc_composition(in_fc, SR=None, prn=True, start=0, end=50)

C:/Arc_projects/CoordGeom/CoordGeom.gdb/Shape2
Shapes :   3
Parts  :   5
  max  :   2
Points :   43
  min  :   4
  median : 9
  max  :   11
     IDs     Part   Points From_pnt   To_pnt
       1        0       11        0       11
       1        1       10       11       21
       2        0        9       21       30
       2        1        9       30       39
       3        0        4       39       43

 

So simple, so...  _common give it a try

More offerings in … npGeo ... numpy geometry 

 

Oh yes... Nice documentation too...