ClueTrust GIS Products


Macintosh GIS

Try Cartographica, the Macintosh GIS today. Explore, analyze, and present geospatial data and maps on your Macintosh.

Get CartoMobile, our field data entry and viewing tool for iOS.

Updates
Blog Index
The journal that this archive was targeting has been deleted. Please update your configuration.
Navigation
Wednesday
Oct102012

Saving Time by Using AppleScript 

AppleScript can make life much easier when performing repetitive tasks. Recently we had an issue with a customer needing to automate the Count Points in Polygons tool across a number of point layers. The process was taking a long time due to the sheer number of point layers being aggregated. To automate the process we wrote a script that will count points from multiple point layers and automatically add new data fields to the polygon layer. The new data fields will be labeled to match the name of the point layer being aggregated.

Here, I'll show an example of this using crime data from from Washington D.C. (The data are available for download at DC GIS). We'll start with the crime data, downloaded from DC GIS, and block group polygons, downloaded from the U.S. Census Bureau. Import the data by choosing File > Import Vector Data. Note that if you download the crime data from DC GIS you will need to create new layers from selections for each of the crime types. Also, note that you can use the script in the example below on any set of point and polygon layers. So if you have point layers you want aggregated to one of your own polygons layers then you can use the script in the exact same way as shown in the example.That is, the script is not written only to be used with data in the example below. 

Cartographica offers a couple ways to complete this task of aggregating points to polygon features. First, you can choose Tools > Counts Points in Polygons. When you have a large number of point layers you will need to perform this task repetitively for each of the point layers that you would like to have aggregated to the polygon layer. When you have many point layers to aggregate, this process can be time consuming. The second option is that you can choose to perform the task by running an AppleScript that will automatically perform the task for you. 

Running the Script

The script is available by the following the link. 

To run the script

1. Make sure your Map window is frontmost in Cartographica

2. Double-click on the script file to open AppleScript Editor

The script we have provided has two parts needing mention. The first part is the script for the Standard Utilities. The Standard Utilities are some additional functions that you can copy and use in your own scripts to handle choosing layers from a list, creating unique layer and column names, and doing numeric conversion. 

The second part is at the bottom of the script where there are commands that performs the repetitive count points in polygons task. The commands are shown below. The first set command tells Cartographica to create a selection box for the point layer that you want aggregated. The second set of commands tells Cartographica to create a selection box fot the polygon layers that you want to have points aggregated on. The final command repeats the process for all selected point layers and adds a count field to the selected polygon layer that contains the original point layer's name. 

tell application "Cartographica"

set selectedLayers to my chooseLayers("Choose the Point layers", the document of the front window, 1, yes) 

set chosenLayers to my chooseLayers("Choose the Polygon layer", the document of the front window, 5, no) set polyLayer to item 1 of chosenLayers

repeat with targetlayer in selectedLayers

add point count polyLayer counting targetlayer column name (name of targetlayer

end repeat

end tell

3. Click Run

After clicking run the program will prompt you with selection boxes. Be sure to select the point layer like shown in the image below. Once you select the point layers click ok. 

After you select the point layers you will be prompted to select the polygon layer that you want the points aggregated to. Select the polygon layer and then click ok. 

The result of running the code should be new fields with names corresponding to the aggregated layer. See below for an example. 

Monday
Sep172012

Negative Buffering in Cartographica

Buffers have many applications for users of GIS. A buffer is a polygon that is drawn at specified distances around a set of point, line, or polygon features. Buffers are often used to indicate the proximity of a feature to other surrounding features. For example, school officials in one community wanted to know which schools were within 500 yards of parks due to increased reports of students skipping school in those locations. 

There are different types of buffers, but the most common method is the Uniform Width Buffer. This method identifies areas that are specific distances from a set of features. In the uniform width method the uniform width is applied to all features in a dataset, or to a number of selected features from a dataset. 

A useful variant of the Uniform Width Buffer is the Negative Buffer, which is exactly the same as Uniform Width Buffering except that the buffer distances are negative values. Negative buffering is only used with polygons because points and lines have no interior space that can be used to take on negative distance buffers. Polygons on the other hand have interior space that is capable of containing negative distance values. Negative buffers are used to indicate distances toward the center of a polygon from the boundary of the polygon. 

Use the following dataset to follow along with this example. 

Parcels Dataset

Streets Dataset

Import the data by choosing File > Import Vector Data. For the scenario in this example we have two datasets. One represents a series of polygons for property parcels in a city neighborhood, and the other represents the streets in those neighborhoods. The city needs you to create two polygon layers one representing a 24 foot easement from the centerline of each street and a second polygon representing a 3 foot interior utility easement within each parcel. 

Start with the Street Buffers. Begin by selecting the Streets layer in the Layer Stack. Choose Tools > Create Buffer for Layer's Features. This will bring up the Buffer Window. The Uniform Width option will be selected. Type in 24 and then change the metrics menu to feet. See below for an example of the Buffer Window and the output. You can change the color scheme for the Streets Buffer layer by double-clicking on the layer in the Layer Stack and then changing the fill and stroke color. For the map below the opacity was set to 0%, the stroke color was changed to blue, and the line width was changed to 3. 

Buffer Window

Uniform Width Buffer for Streets Layer

Negative Buffer for Parcels Layer

The negative buffer in this scenario represents a 3 foot utility easement that is in place to ensure, among other things, that utility vehicles can get between houses if necessary. The city wants a polygon layer representing these easements. Select the Parcels layer in the Layer Stack and then&nbsp;<strong>Choose Tools &gt; Create Buffer for Layer's Features</strong>. &nbsp;Again, the Buffer Window will appear. This time type in -3, change the metrics menu to feet and then click Buffer...Change the color scheme for the Parcels Buffer Layer by double-clicking on the layer in the Layer Stack. In the map below the fill color was eliminated by changing the opacity to 0%, the stroke color was changed to red, and the line width was changed to 1.5.

Wednesday
Sep052012

Mapping 7.6 Earthquake in Costa Rica

There was a large (7.6) earthquake yesterday in Costa Rica. The earthquake signaled tsunami warnings in the region, but fortunately there was no tsunami. So far there have been three deaths reported. In the past 40 years Costa Rica has experienced more than 30 earthquakes of 6.0 magnitude or higher. So, needless to say Costa Ricans are accustomed to these types of events.

The purpose of this post is two-fold. The first purpose is to draw people's attention to the major geologic event that occurred in Costa Rica yesterday. The second purpose is to show a couple quick methods for creating concentric rings, which we have had questions about from some of our customers in the past. Concentric rings are used in a variety of ways, but one way you often see them used is in reporting the location of earthquakes.

Start by Adding a Live Map by choosing File > Add Live Map. After you add a live map choose Layer > Include in Map Extent. Including the Live Map layer in the map extent is necessary because it will enable the zoom functions to operate beyond the extent of the point layer that you are about to create in the following steps.

According to reports the earthquake occurred just off the cost of Costa Rica. To add a point representing the location of the earthquake choose Layer > New Layer and then choose Edit > Add Feature. A window will appear allowing you to choose the type of feature you would like to create. Select Point and then place the point by holding down the option key and clicking on the location about 50 miles off the coast. See below for an example.

There are two options for creating concentric rings. The first method involves using the buffer tool to create rings around a point at specific distances. To create a buffer choose Tools > Create Buffers for Layer's Features. A window will appear that will allow you to set the parameters of the buffer. Set the Uniform Width distance to 25 Miles. See below for an example.

To create new buffers at different distances select the Earthquake point layer in the Layer Stack, and then repeat the steps above to create buffers around the Earthquake point at 10, 50, and 75 miles. (Note: Be sure after each buffer is completed that you re-select the Earthquake point layer before creating the next buffer). When completed you will have four layers that are represented on the map by white circles. Double-click on the top buffer layer in the layer stack, click on the Fill box and then change the layer opacity to zero. Next click on the stroke box and change the color to red. See below for an example.

 To make all of the buffer layers have the same layer styles drag the top layer in the layer stack (the one you have already changed) on top of the other buffer layers. This will automatically match the layer styles. See below for a final image of the concentric rings created by using buffers.

The other method for creating concentric rings is to use an image from the internet. This method is not as precise as the buffer method because you cannot designate the distances for each ring. However, it is a quick alternative method for creating concentric rings. The first step is performing an image search for "concentric rings" using Google or a similar search engine. Find a clean looking example of concentric rings. Double-click on the earthquake layer in the layer stack and then click and drag your concentric ring image to the symbol box in the Layer Styles Window. Finally, change the stroke color to red and increase the point to a desired size . See below for an example of the Layer Styles window.

 Uncheck the four buffer layers that you created previously to reveal to new concentric rings that were created with an image from the internet. See below for an example of the final map.

Wednesday
Aug292012

Mapping West Nile Virus in the United States

West Nile has increasingly become a concern of U.S. health professionals and officials at the Center for Disease Control and Prevention. A recent interview reported in USA Today revealed the concern that the CDC is giving the recent West Nile outbreak. According to the article, CDC Director of Vector-Borne Infectious Disease, Lyle Petersen, is quoted as stating, "We think the numbers may come close to or even exceed the total number of cases reported in 2002 and 2003, both of which were severe West Nile virus years." According to CDC numbers there were more than 250 deaths due to West Nile in 2003. Obviously, the concern of the CDC official is understandable. 

In order to provide a little more context to this situation I have created a dataset that is available for download. Click on this link to download the West_Nile.csv data. The dataset was created based on numbers provided by this CDC Webpage. The dataset provides the current number of positive tests for the West Nile virus. The link to the CDC webpage in the previous sentence also provides a county level map showing the specific counties where West Nile has been confirmed. Unfortunately, the county level data are not available for download.

In order to create a state level map you will need a map of the US to import into Cartographica. Download a map of the lower 48 states here

To create the West Nile map begin by importing the data.

Choose File > Import Vector Data and choose Lower48.shp

Next, you need to join the West_Nile.csv file to the Lower48.shp file. 

Choose File > Import Table Data  and choose West_Nile.csv  This will bring up the Import File Window. 

Click the Join tab in the top right, change the Target Layer selection to Lower 48, and then match the two files together by changing the Map to selection in the State_2 field to State, click on the check box, and then click Import. Below is an image of the set up. 

Bring up the Layer Styles window by double-clicking on the Lower48 layer in the layer stack. Create a chloropleth map by adding 6 categories to the table by clicking on the + button 6 times. Distribute the West Nile Incidents by changing the Based on selection to West Nile Incidents and then clicking on the Gear Box and selecting distribute with Natural Breaks (Jenks). You can assign a color scheme by choosing Window > Show Color Palettes and then clicking and dragging a color scheme to the table within the Layer Styles window. Below is an image of the set up.

Below is an image of the final map for the West Nile Incidents in US states below. 

 

Tuesday
Aug212012

Mapping Wildfires in Russia and Asia

Drought conditions and high temperatures throughout the world are causing problems with wildfires. There are presently several thousand wildfires burning throughout the world, which have resulted in millions of dollars worth of damage. NASA has made available a set of shapefiles that identify the locations of wildfires presently burning throughout the world. The shapefiles are nearly real-time with data available at time intervals of 24 hours, 48 hours, and 7 days. Click on the following link to Download the wildfire data

For this post I downloaded the wildfire data from Russia and Asia. Once the data are downloaded import them into Cartographica by choosing File > Import Vector Data. I provide an image below of the map of Russian and Asian wild fires. 

To enhance the fire map you can change the point symbols from circles to an actual fire symbol. To do this go to Google and perform an image search for "Fire". You will be able to find an image that can be dragged to the Layer Styles window. To open the Layer Styles window double click on the Russia and Asia fire layer in the Layer Stack. Then drag the fire image to the symbol box within the Layer Styles window. Once the image is added uncheck the stroke box. See my images below. 

Below is an image with the fire symbols.

A final map shown below was created using the Kernel Density function. To create a Kernel Density map choose Tools > (while holding down the option button) Make Kernel Density Map. Choose the Exponential (Negative) function and click Analyze. I provide an image of the Kernel Density window below.

My final map shown below is of the Kernel Density of wild fires in Russia and Asia. To change the color scheme choose Window > Show Color Palettes. Select the color scheme you would like to use and then click and drag it to the KDM layer in the Layer Stack. The color scheme I selected is a custom color scheme called Fire Ramp.