Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Tuesday, August 10, 2021

ArcGIS Online Application Transparency Issue

Issue

I published a Map in ArcGIS Online, and converted it to an Application to add some custom functionality (splash disclaimer, print button, etc.). Unfortunately, there is a city boundary layer that is displaying with a 60% transparency, and the requestor wants this to be much darker. I cannot seem to adjust this at the Application level.

Application view

 

 The layer in the map has all transparency removed in the Symbology properties, as well as in the layer's Appearance settings. Despite removing and re-adding the hosted feature layer, the Application still renders the transparency.

Map view

Solution

 Check the settings at the feature layer level:
  • In ArcGIS Online/your Portal, navigate to Content 
  • Search for- and open the hosted feature layer
  • Navigate to the Visualization tab
  • Click the Change Style icon  
  • Click the Options button to open the symbol properties
  • Review the Overall Transparency setting and adjust if necessary
60% Transparency applied

Discussion

 In my case, this is where the issue originated. After I set the Overall Transparency to 0%, the property was able to propagate through to the Application level. Despite explicitly configuring the transparency in the Map that is directly consumed by the Application, the Application still reached across the Map and pulled the default transparency variable that was defined in the feature layer.

That is annoying because I had intended for the default City Boundary layer to render with a decent amount of transparency; and this application is an outlier from the otherwise uniform graphic standard I was hoping to implement.

Alternatively, I'll try to apply a transparency value inside the symbol fill/outline settings, rather than at the Overall layer transparency. 💁

 


 

 

 

 

 

Thursday, March 24, 2016

Problems with Font Awesome Icons

I love Font Awesome, but it's been a pain in the ass for me to work with their icons on my Windows machine using Inkscape. I blame this on Inkscape's buggy text element interface, but I'm happy to use it as a free, open source package.

Anyhow, it's hard to select an icon from the Font Awesome Cheatsheet or from individual icon pages becasue I'm not able to select the icon directly. I end up copying a space character.


I ended up relying on Microsoft word to act as a medium to get access to copying the character:

  • Open Word
  • Type the Unicode address, for instance f041
  • Select the 4-digit code and hit Alt+x to convert the unicode value to its designated character
  • Change the font of the unknown character to FontAwesome, then I can finally move on with my life...
Even after I'm able to copy the desired character from Word, Inkscape still doesn't always work since it's a nightmare tying to tell Inkscape to render the character using the FontAwesome font.

Anyway, here are a few things to consider to ease the transition

Download the Latest Font File

If you have any problem, first update to the latest Font Awesome font file:
  • Uninstall any current Font Awesome fonts you have installed. Make sure to close any software that's running it including Inkscpae, Gimp, Illustrator, or even Word or Outlook just to be safe
  • Go to FontAwesome.io and click the Download button to grab the latest version
  • Install the .ttf file and try again

Chrome Won't Let me Select Icons

I found a cool Chrome extension that streamlines the search-copy method.

Download the Font Awesome Icon Picker extension for Chrome for a quick Font Awesome reference. It'll let you easily navigate the catalog of icons, and most importantly, it allows you to directly highlight and copy individual icons.


Since I started using this, I haven't had a problem directly pasting the desired icon directly into Inkscape.

Thursday, December 3, 2015

Automating Password Management

I have a password that I don't particularly need to be super secret, but I don't really want to memorize another password either.

I  put together a script that will automatically copy the password to the clipboard (essentially a Control + C command of text). I threw this into a project folder and I can run the script quickly by double clicking it.

For the sake of slight security, I named the file something boring and unrelated.

Code

from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append('password')
r.destroy()


Setup

  • Install Python if it's not already installed
  • Copy the code above
  • Paste into Notepad or another text editor
  • Replace the highlighted password with your own password
  • Save as type: All Files (*.*)
  • File Name: "SomeFileName.py"
    • Wrapping the filename in quotes ensures the file type will be set to .py - a python script file
  • Double click on the file to run it. A Python window will briefly open and close automatically
  • Navigate to a text area and hit Ctrl+V or use some other paste command

Sunday, November 29, 2015

Color Development: Tools and Methods

I accidentally went nuts writing about the basics of digital color, so I decided to make it a separate article.  Check that out:
Color Development: Digital Color Basics
In this article, I'll list a few tools I use for color development, and discuss how I like to brew and develop colors in graphic design and cartography environments.

Color Brewing

These are some of my favorite tools to build and tune color sets.

Browser Utilities

ColorPick Eyedropper



ColorPick Eyedropper is a Chrome extension that enables you to quickly grab a color from a Web page. There's even a rad little magnifying visualization that helps zero in on the exact pixel you need.



Desktop Utilities

ColorPic


ColorPic is a great desktop tool to help snag Hex, HSV, RGB, CMYK, values, and save your own custom groups of color. There are even sliders, and grids to use to help build or tune your colors if necessary.

ColorOracle

ColorOracle is a fantastic color deficiency simulator. It's a quick way to preview your entire monitor view for any potential issues with color patterns which may be difficult to read for those with color-vision impairments. No exporting


Sunday, June 7, 2015

Make New Project Directory

I like to organize photos, videos, GIS projects, and developments projects in separate "project directories." Each project folder has the following format:
YYYY-MM-DD - Description

File Structure Example:
  • [Drive]:\
    • Development
      • 2014-10-04 - Scuba Calculators
      • 2015-06-01 - Make New Project Directory
    • GIS
      • 2012-05-14 - Whatever Project...
        • Shapefiles
        • Exports
        • From Client
        • MXDs
    • Photos
      • 2013-04-05 - Birthday in Midtown
        • Hilights
          • Edited
        • Original
      • ...
    • Videos

This is an easy way to chronologically catalog projects within their respective folders, but I'm lazy, and I hate having to look down at my task bar clock to find out what the date is, and I can't stand typing in that endless date!

Solutions Posted on GitHub

I posted all the scripts I came up with for this on my GitHub page under the Make New Project Directory repo.

Batch File

I originally tried coming up with a Batch file (.bat) to add the folder using the format I wanted. It's easy to make a predefined folder structure using CMD commands, but pulling that date style turned out to be a little tricky, so I looked elsewhere.

Python Script

I came up with a great Python script that will automatically add a folder that's named with the current date followed by XXXXDescriptionXXXX (so I could easily find and rename it further). Just double click the python file and the new project folder is added. Additionally, I repeated the code to add subdirectories for common sub-folders: Exports and Shapefiles for GIS projects; Originals, Highlights, and Edited for photos & video; etc.


Pros:

  • This is great! It works automatically
  • Simple code. It executes in 6 lines.  View the code here

Cons:

  • I quickly realized how awfully tedious it is to have to slow double click to rename, something every time I create a new project. I need some kind of interface to enter a project name, and I haven't had great luck using TkInter yet.
Note: I've heard good things about PyQt for an interface
  • I don't necessarily want those sub-directories for every project

VBScript

My best solution so far was to write a VBScript (.vbs format) to prompt me for a project name AND ask if I want to add those common project sub-folders.






Pros:

  • Most efficient method so far
  • Quick, easy, no renaming
Cons:


  • Slightly longer code (24 lines without comments & line continuation), but it does include some more logic handling. View the code here.
  • This is still generalized, and the "common subdirectories" option is hard coded (i.e. I don't need a Shapefiles directory in a video editing project).
Overall, This VBScript method opens the door to writing a slightly larger executable in Visual Studio with a more dynamic interface to add any kind of project folder - but that moves away from the original requirement of a highly rapid way to add a project folder automatically. I think this nails it.




    Tuesday, March 24, 2015

    Color Development: Digital Color Basics

    I intended to just write about how to create colors and suggest some cool tools I've found, but this got out of control. Check out the next article:

    Color Development: Tools and Methods

    There are various ways of building colors for a project or symbol. For general, rapid selection, users are often offered a basic color palette to select a color:

    Default color palette from ArcMap

    Color palette from Word

    Even MS Paint offers a few basic colors
    Notice that each of these provide an option to edit the color further.

    Color Values

    Colors commonly have names: like Black, White, Red, Orange, Yellow, Green, Blue, Purple, Cyan, Magenta, Olive Drab, etc.
    ! Specifics aside, Black, White, and shades of grays are referred to as colors here
    Various environments like CSS, and HTML accept some reserved names to act as color values, however those names correspond to very specific numeric values (discussed below), and can be easily referenced on lists like this one. A color isn't "like red" to a computer. It's Red, or it's not.

    In the world of coding, there's a need to describe color in a more articulate way than just names. Due to the diverse nature of how light acts (See Further Reading, at the end of this article), there are also a number of different methods that programmers and graphic artists use to build and digitally represent color. Although the various methods may describe a color value differently, they are basically just providing a group of three or more numerical values that act as measurements of various criteria that go into building a representation of color. There are four types of units you may expect to see in these groupings:
    • Percentage - values from 0 to 100%
    • 8-bit - Values from 0 to 255
    • Hex - Values from 00 to FF
      • As in 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 11, 12, etc.
    • Degrees - Values from 0 to 360º
    Zero will always equal zero in any of the first three modes, but the "full" value values will be either 100%, 255, or FF. Those three are all equal values, written in different base units; in the same way that a measurement of 10 centimeters  is 100% of 3.93701 inches.

    I'll get to degrees later in HSV/HSL.

    Color Models

    RGB

    RGB Selector in ArcMap

    The RGB triad stands for Red, Green, and Blue. Colors in this model are altered by adding or subtracting values in for any of the three primary color channels. As an "additive model," greater values result in brighter color instances, and lower values result in darker colors. This is based on a model of emitted light, where mixing red, green, and blue light produce the color white.

    Users can adjust the sliders in this interface to control values of each of these channels between values of 0 and 255; where 0 = no value, and 255 = the full value of a given channel.

    Alternatively, users can type a number they have in mind - this is particularly helpful when one wants to jump between increments of a values when searching for a color to use (e.g. changing the red value from 10, to 20, to 30, using the keyboard's number pad).

    Color values are read as (#, #, #) or 
    (Red value, Green value, Blue value). Since the RGB model is 24-bit (16.7 million possible color combinations), the values in each of the three channels will be some combination between 0 and 255.

    As the example above illustrates, to build the color Red, tune the Red channel all the way up to 255, and leave Green and Blue channels at 0 since there should be no other color in Red but red. Done. Aside from various settings on your personal monitor, this is the standard, globally accepted, fullest possible value of Red.

    Mixing two of the primary colors, Red, Green, or Blue produces
    the "additive secondary" colors, Cyan, Magenta, and Yellow.
    Mixing all three primary colors produces White.


    The value (0, 0, 0) produces Black (the absence of light), and (255, 255, 255) produces White. Shades of gray are produced by matching all three values from (1, 1, 1) (darkest gray but not Black) to (254, 254. 254) (lightest gray but not White).



    Back to our example of building the color Red, adding some value to the Green or Blue channels will yield some other color that may look reddish, but it isn't Red.

    Additonally, the ArcMap interface gives you hints as to what other colors can be created from the current settings. With Red at 255, adjusting the Green channel will produces shades of red, through orange, and finally arriving at Yellow. Alternatively, adjusting the Blue channel will move through shades of reds and pinks and finally arrive at Magenta.

    This is a good model to use to begin learning how to mix colors, but it's not my preferred model to use because it's tricky to imagine how to add a little red or remove a little green to target your preferred color.

    CMYK

    CMYK is a subtractive color model, used most often when printing is involved as an output medium. Pigments and inks absorb light (as opposed to how RGB works to emulate emitted light), so this model helps printers create the correct color with their ink print heads, as opposed to a computer monitor's LED pixels.

    CMYK stands for Cyan-Magenta-Yellow-Key, where Key represents a black ink head. Black is used in printers as an efficient and controlled way to provide shadows, dark values, and black text to the printed material.

    Just like mixing color with paint (where light is absorbed and the remaining wavelengths provide the observer perceived color), the CMYK model begins with the color white. Value is added to the channels, and lightness is removed. So zero values are White, and full values in all channels produce Black. Additionally, a full value in the Key channel also produces Black, regardless of the settings in the CMY channels.

    Notice that the secondary colors in the RGB model produce Cyan, Magenta, and Yellow. Conversely, mixing two primary colors in the CMYK model will produce Red, Green, and Blue.

    This is also not my favorite model to use to produce color, and it's generally just a pain in my ass when I'm printing large format maps.

    HSV / HSL / HSVa / HSLa

    HSV dialog in ArcMap

    HSV selectors in Gimp, adjacent to RGB selectors
    with the Hex code value, below

    HSLa Selectors in Inkscape

    These triads stand for Hue-Saturation-Value, and  Hue-Saturation-Lightness. The following "a" stands for Alpha, which is a metric of transparency. Sometimes this is included as a channel, sometimes it isn't. It's very important to recognize whether or not it's included. If you don't want to bother, make sure it is set to 100%, or 255, or FF.

    This model is a bit tricky, so let's break it down.

    Hue can be though of as the root color you're looking for on the color wheel: either a reddish, or a blueish, or a yellowish color, etc. The wheel starts at 0º, and continues through oranges, yellows, greens, blues etc, and eventually ends back at red at 360º; which also = 0º, but that's okay because both values are the same red.

    A color wheel with 0° and 360° at the 12:00 position


    Next, Saturation describes how muted gray (lack of color) or vibrant (fully colored) a color should be. This is usually a percentage, where 0 means no color is present and 100% represents the full colored potential of a color.

    Examples of saturation gradients for several hues,
    which correspond to the color wheel, above
    ! Note that the units can change between software packages. Inkscape uses 8-bit values (numbers 0-255) for each, HSLa channel. So a Hue value of 255 will correlate to 360° on the color wheel, and a 255 in the Saturation channel is equivalent to 100% saturation.

    If you are building colors that are way off, you may need to check your units and convert when necessary.
    Finally, Value and Lightness and are.. Also a bit tricky. Go ahead and read about the differences over on Wikipedia. Essentially, this component controls how light or dark a color will be.

    Zero values in both HSV and HSL produce the color Black, regardless of Hue or Saturation settings.

    The main difference between Value and Lightness is that the highest Value setting produces a fully saturated color (see the Saturation illustration above, and the ArcMap HSV selector below), and



    the highest Lightness setting will produce a pure White color (see the Inkscape HSL selector below). A fully saturated color using HSL will have a Lightness value of 50% - or 128 (as Inkscape uses 8-bit values for each channel).


    Hex

    I didn't really touch on Hex, other than that it is another method of preserving a value of color. There's not much to it. It essentially is just a concatenation of the three or more channels in the fewest logical number of characters.

    Short answer: Hexadecimal notation throws a couple of letters after the number 9 so each significant figure can be one of 16 possible values:

    0 1 2 3 4 5 6 7 8  9  A  B  C  D  E  F
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

    Hex usually stands for RRGGBB, and sometimes for RRGGBBAA (for Alpha).

    To find the Hex value of Red using the common six-digit RRGGBB method, first find the RGB value of Red:

      (255, 0, 0)

    Then convert each value to its hex equivalent:

    (FF, 00, 00)

    Finally, remove the formatting, and stick the three values together:

    FF0000
    123456

    For Inkscape and the few other examples of hex RGBa values, just throw another set of F's on the end. Here, we'll have a fully opaque value of Red:

    FF0000FF
    12345678

    HTML & CSS

    There are two ways to write hex color values in CSS and HTML.

    There's the long way (again, using Red as an example):

    #FF0000

    And when all three RGB channels use doubled digits for their channel, you can use a 3-digit format:

    #F00

    Additional examples:

    #112233 = #123
    #00FF00 = #0F0
    #333333 = #333

    Further Reading

    The physics of light are fascinating. I learned a lot about the subject in my various Remote Sensing courses in grad school, and in the practice of GIS and graphic design over the years. There are plenty of other great resources to use on these matters. Here are a few search terms to consider:
    • Emitted vs. Reflected light
    • Additive vs. Subtractive color
    • Color models
    • Primary color of light and pigment
    • Light vs. Pigments
    • Pigment vs. Dye
    • Blackbody radiators
    • Color theory

    Friday, February 14, 2014

    Manage SD Card Media with an Android Tablet

    I love my Nexus 7.  It's the 2012 version and when I got it for Hanukkah, I pretty much entirely stopped using my laptop.  It's a large enough screen while still being small, light, and portable. It's powerful enough to be a solid graphics post-production workstation for photos from my adventures, and it was quite a bit less expensive than similar tablets.  There are tons of really powerful (FREE) apps that can tune my pictures and really make my photos pop!

    The only drawback to the Nexus is that I've had to transfer media from my old GoPro HD Hero or my point & shoot camera to an intermediate device before I can dig into editing the files on the tablet.  I'll have to:
    1. Connect the camera/card to a computer
    2. Transfer the files to the computer
    3. Connect the tablet to the computer and transfer again, or e-mail the photos to myself
    This also implies that I have both a mini-USB cable for the cameras, and a micro-USB cable for the tablet.

    Solution:


    1. Any micro-USB OTG cable ("On The Go" cable): $1-2

    1. Nexus Media Importer app: $4 on Google Play

    Setup:

    1. Buy the card reader and the OTG cable. With shipping, it's still probably under $10.
    2. Download Homesoft's Nexus Media Viewer and test out your new cable and card reader. If you can successfully view photos with this app, uninstall it and buy the Nexus Media Importer app
    That's it! It's a pretty solid app.  Simple to use, simple to copy data to your tablet, and it has some pretty sweet methods to select the specific files or groups of files that you want out of a given directory.

    It also works for other types of data (video, music, documents, folders, etc.)

    Friday, August 12, 2011

    Connect to ArcMap layers and tables with VBA

    Example description:
    I am editing a coverage of stream segments (lines) and would like to log any updates to a non-spatial, standalone table in the geodatabase so I can keep track of the evolution of the dataset over time.  The application will first need to know which datasets to edit, so I start by adding  two combo boxes to the form that will be automatically populated with the two necessary types of data, named cboFlowingWatersLayer, and cboFlowingWatersUpdateTable, respectively.


    The first combo box will allow me to select any of the the spatial datasets (geodatabase coverages/feature classes/shapefiles/projected datasets/etc.) that are available in the Table of Contents pane:

    Map layers in an active ArcMap project

    The second combo box will select the non-spatial, standalone table (highlighted below) that is otherwise available under the Source tab in the Table of Contents pane.  There are two additional dummy tables that I added to this project that are not visible in the screenshot below, but you'll see them later.

    Non-spatial tables in an ArcMap project

    Coding:
    I add some code to populate the combo boxes with any available layers or standalone tables when the form activates.  There's a brief Setup section, then an If/Then statement will check to see if there is a layer already set in there.  If not, it'll clear it and populate the control with any spatial layers that are available.  If there is anything in there, it will run a separate function to check if it's the right layer.  I won't address that procedure here, so it's commented out below (though I recommend adding such a function). Let's get started with filling in the names of just the spatial datasets first:

    Private Sub UserForm_Activeate()
    'Setup
      Dim pMxDoc As IMxDocument
      Dim pMap As IMap

      Set pMxDoc = ThisDocument
     
    Set pMap = pMxDoc.FocusMap

    'Populate the first combo box with any available spatial
    ' layers that will show up in the Display tab in the
    ' ArcMap Table of Contents pane
      Dim i As Integer
      If cboFlowingWatersLayer.ListCount = 0 Then
          cboFlowingWatersLayer.Clear
          For i = 0 To pMap.LayerCount - 1
              Me.cboFlowingWatersLayer.Additem (pMap.Layer(i).Name)
          Next i
      Else
          'Call Me.FlowingWatersLayerCheck
      End If

    End Sub

    What should appear when the first combo box is selected are any layers that are available the Display tab of an ArcMap project.


    (Note that apps can only work with shapefiles, geodatabase coverages, etc. and not groups of data.  Data groups appear in this example as individual layers, but since they are not really spatial datasets, selecting them will cause an error at run time if they are selected and processed.)

    Next we'll add some more code to add any standalone tables that are in the project using the IStandaloneTableCollection interface:

    Private Sub UserForm_Activeate()
    'Setup
      Dim pMxDoc As IMxDocument
      Dim pMap As IMap
      Dim pSATCollection As IStandaloneTableCollection 

      Set pMxDoc = ThisDocument
     
    Set pMap = pMxDoc.FocusMap
     
    Set pSATCollection = pMxDoc.FocusMap

    'Populate the first combo box with any available spatial
    ' layers that will show up in the Display tab in the
    ' ArcMap Table of Contents pane
      Dim i As Integer
      If cboFlowingWatersLayer.ListCount = 0 Then
          cboFlowingWatersLayer.Clear
          For i = 0 To pMap.LayerCount - 1
              Me.cboFlowingWatersLayer.Additem (pMap.Layer(i).Name)
          Next i
      Else
          'Call Me.FlowingWatersLayerCheck
      End If

    'Populate the second combo box with any available non-spatial
    ' tables that will show up in the Source tab in the
    ' ArcMap Table of Contents pane
      Dim j As Integer
      If cboFlowingWatersUpdateTable.ListCount = 0 Then
          cboFlowingWatersUpdateTable.Clear
          For j = 0 To pSATCollection.StandaloneTableCount - 1
              Me.cboFlowingWatersUpdateTable.Additem _
                  (pSATCollection.StandaloneTable(j).Name)
          Next j
      Else
          'Call Me.FlowingWatersTableCheck
      End If

    End Sub

    Finally, this is what the second combo box will look like (with the additional two dummy datasets that were hidden from view in the screenshot above - they're named "Delete - Test 1" and "Delete - Test 2"):


    Referencing the selected layer/table:
    There are a virtually unlimited number of uses for mapping layers like this.  The idea is that the method above provides a heads-up interface to access the position of a given layer or table in the Table of Contents.  Think of the position as the dataset's number in line, starting at 0 instead of 1.  Take the five spatial "layers" that are available for example:

    Place in lineVB Position #Layer Name
    1st / Top
    2nd
    3rd
    4th
    5th / Bottom
    0
    1
    2
    3
    4
    "FlowingWaters layer"
    "New Group Layer"
    "Florida NHD"
    "SWFWMD_draft_primary_canals"
    "Reporting Units"

    Whenever you need to use a specific layer, the interface we built above will allow a quick way for Visual Basic to reference the position number of a selected layer.  Of course you will need some error checking and handling code to ensure that the layer position isn't changed (adding, removing, or moving the order of layers in the Table of Contents will affect each layer's position number).

    The following are a few examples on how to reference a layer's position number using the interface that we built above.

    Example 1 - Connect to a dataset:
    A working example follows, so don't worry about the function of the code yet.  This simply illustrates the structure of references needed to connect to a dataset.

    The previous sections explain that an ArcMap project is made of up layers and sometimes non-spatial tables.  Further, those layers and tables have position numbers associated with them that are usually just unimportant background information.  Well, now we will use those position numbers to tell a program where to target its procedures.

    After we choose a layer from the program interface, that combo box/pull down menu will store our selection as a number, which it refers to as its ListIndex.  Now if we want to know which layer or table we chose, we'll call it by referencing cboFlowingWatersLayer.ListIndex.

    In the example below, we are instantiating a new variable based off of the IFeatureLayer interface (again, don't worry about what's happening yet).  We will set that new variable, named pFeatureLayer, equal to a specific layer number (position number) in an ArcMap project so we can do some more work on it later.  Just pay attention to the way that the combo box position is referenced:

    Dim pMxDoc As IMxDocument 'Whatever
    Dim pFeatureLayer As IFeatureClass 'Slightly Important
    '...more code

    Set pMxDoc = ThisDocument 'Still not the point
    'Oh, here we go!
    Set pFeatureLayer = _
      pMxDoc.FocusMap.Layer(cboFlowingWatersLayer.ListIndex)
    '...more code


    Ok! This essentially told the function/sub routine that:
    1. We're working with this project (aka ThisDocument)
    2. We're looking for a specific feature layer (spatial dataset/shapefile/geodatabase coverage/etc.)
    3. That dataset of interest will be in a certain position when you focus the map; and that position number can be found by A) looking at the combo box (pull down menu named cboFlowingWatersLayer) and B) pulling its current ListIndex value.
    Got it.  Let's move on to a working example.

    Example 2 - Count the selected spatial features:
    Add two command buttons to the form, named cboLayerCount & cboTableCount, and change their captions to match the screenshot below

    Added two command buttons

    When a user clicks on one of these buttons, a message box will report how many records are selected in a layer or a table.  I'll add a quick error check at the beginning to make sure that a layer has been selected.  If a layer has not been selected yet, the ListIndex value will be -1. Here's the code:


    Private Sub cmdLayerCount_Click()
    'Error Checking
      If cboFlowingWatersLayer.ListIndex = -1 Then
          MsgBox "Please choose a layer to count."
          Exit Sub
      End If

    'Setup
      Dim pMxDoc As IMxDocument
      Dim pMap As IMap
      Dim pFS As IFeatureSelection
      Dim pSelectedFeatures As ISelectionSet

      Set pMxDoc = ThisDocument
      Set pMap = pMxDoc.FocusMap
      Set pFS = pMap.Layer(cboFlowingWatersLayer.ListIndex)
      Set pSelectedFeatures = pFS.SelectionSet 

    'Display a message box to report info
      If pSelectedFeatures.Count = 1 Then
        MsgBox "There is 1 feature selected."
      Else
        MsgBox "There are " & pSelectedFeatures.Count & _
            " features selected."
      End If

    End Sub

    Save this, run the code, select a few features and you should get something like this:


    Example 3 - Count the selected standalone table features
    Using the same GUI (graphic user interface) that was built in the previous example, apply the following code to the "Table Count" command button to count the number of selected records in a standalone table.  A very similar method will be used for this procedure, however we will need to use the ITableSelection inteface in place of the IFeatureSelection interface since we're working with a standalone table instead of a spatial dataset.  Further, I won't need to sort through any of the selected features in the standalone table in my larger project, so I'll leave out the Selection Set and count directly from my Table Selection:

    Private Sub cmdTableCount_Click()
    'Error Checking
      If cboFlowingWatersUpdateTable.ListIndex = -1 Then
          MsgBox "Please choose a layer to count."
          Exit Sub
      End If

    'Setup
      Dim pMxDoc As IMxDocument
      Dim pSATCollection As IStandAloneTableCollection
      Dim pTS As ITableSelection

      Set pMxDoc = ThisDocument
      Set pSATCollection = pMxDoc.FocusMap
    'This next bit must be on the a single line;
    '  the format of this blog makes coding difficult.
      Set pTS = pSATCollection.StandaloneTable(
           cboFlowingWatersUpdateTable.ListIndex)

    'Display a message box to report info
      If pTS.SelectionSet.Count = 1 Then  
          MsgBox "There is 1 feature selected."
      Else 
          MsgBox "There are " & pTS.SelectionSet.Count & _
              " features selected."
      End If

    End Sub

    Now, after you map a standalone table in the Flowing Waters Update Table combo box and click the Table Count command button, you will be able to count any selected records in the table, just like you would count the records in a spatial layer.


    Thursday, July 15, 2010

    Tech Mashup Idea: Live Street View for Google Maps

    Cell phone cameras are getting much more impressive.  I just saw an 8 megapixel HD camera on an Android  phone.  Neat.  Also about time.  Android also has lots of great apps too (I really need to dig into Java programming a bit more).  After all, it's free to develop apps (eclipse.org, android.com, etc.) for it.  A friend (@alanlupsha) and I were swapping app ideas when it finally hit me: live street view feeds.

    Given that phones have:
    • high quality cameras to capture photos and video
    • the ability to record a lat/long position, and a bearing & angle (via compass app/tilt/acceleratometers)
    • the ability to send data and communicate with other devices/computers
    then this app can:
    • automatically geotag photos with a lat/long, direction, and angle OR
      automatically geotag frames of a video with locations along a recorded along a path (also see RoboGEO software)
    • upload geotagged media to a server when you return to your home wifi connection, or any other wifi hotspot (@alanlupsha)
    • server geocodes the images (with minimal effort now) and updates an internet mapping application view that can be shared individually as a single view (see Google's Street View @ the 2010 Olympic ski runs)

    Wednesday, April 28, 2010

    Install Non-Packaged 3rd Party GIS Plugins

    Many third party GIS plugins have been neatly packaged into .dll files or batch files (ET GeoWizards, arcscripts.esri.com/resources.arcgis.com, etc.) that can be installed or imported into ones software interface in one step.  This easy method is not always available.  Below is an example of how to install a non-packaged plugin.  For further explanation on any of these steps, refer to a previous article on GIS Desktop Customization.

    I'll use my Attribution Assistant in the following example - Download the installation package (12 kb)

    What's included:
    • _Attribution_Icon.bmp is a graphic to use as the icon that will be used to launch the tool from the ArcMap interface
    • frmAttribution v2.0.frm is the form that will be imported into ArcMap.  The source code is stored in this file, and can be viewed when opened by a text editor.  Do not change any of these settings via text editor.
    • frmAttribution v2.0.frx a VB binary file that accompanies the .frm file that holds graphics and other information that will be used by the application
    • Installation instructions.txt is a "Readme" text file with information about the plugin

    Install:
    • Open ArcMap
    • Open the Visual Basic Editor from Tools menu under Tools :: Macros :: Visual Basic Editor
    • Locate the Project Explorer (see below).  If you want the tool to be available every time you open ArcMap, you'll import the plugin under the Normal.mxt branch.  Otherwise, installing the application under the Project branch in the Project Explorer will only allow access to the tool when working under a specific ArcMap project (a saved .mxd file).
    Undocked Visual Basic Project Explorer
    • Right click on the Normal branch and choose Import File so the plugin will be available every time ArcMap is opened.  Navigate to where the install package was unzipped, choose frmAttribution v2.0.frm and click Open.  Expand Normal and Forms to view the new form (see below), otherwise close the Visual Basic Editor.
     frmAttribution successfully imported
    • Back in ArcMap open the Customize dialog via Tools :: Customize
    • Navigate to the Commands tab
    • Ensure that the Save in: setting is set to Normal.mxt to ensure that the tool will be available every time ArcMap is opened
    • Scroll to the bottom of the Categories menu and select [ UI Controls ]
    • Click the New UIControl button, choose UIButton Control
    • Slow double click on the new control probably named Normal.UIButtonControl1 in the Commands list and rename it "Attribution_Launch."  When you press enter it will automatically rename itself "Normal.Attribution_Launch"
    •  Drag the new control onto the ArcMap interface
    •  Change the button face icon: With the Customize dialog still opened, right click on the icon that was just dropped onto the ArcMap interface and under the Change Button Image sub-menu, choose Browse
    • Navigate to the directory where the installation package was unzipped, choose _Attribution_Icon.bmp and click Open
    •  With the Customize dialog still open, right click on the new button on the ArcMap interface one more time and choose View Source.  The Visual Basic Editor will open, and will automatically open the ThisDocument code under Normal.mxt, with some code written for you (don't worry if you don't completely understand this part, just follow the directions to get through it)
    • Copy and following line and paste it into the Attribution_Launch_Click subroutine:
      Normal.frmAttribution.Show (vbModeless)
      It should look like the following:
    Private Sub Attribution_Launch_Click() 
        Normal.frmAttribution.Show (vbModeless)
    End Sub

    • Close the Visual Basic Editor when finished and you're good to go!  Click on your new button to launch the newly imported ArcMap plugin!