Archive for the ‘scripting’ Category

Calculating bounding box in ArcMap

Monday, July 12th, 2010

xmindimen

[Editor's note: I keep returning to this technique for calculating a feature's extent (minimum bounding rectangle) in ArcGIS using the Field Calculator. Thanks William and Jeff!]

Republished in part from ESRI Forums.
Sample Field Calculator code for computing XMIN appears below.

Information about shape properties appears in the “Geometry Object
Model
” diagram (pdf). All four parameters are Xmin, Xmax, Ymin, and Ymax.

dim Output as double
dim pGeom as IGeometry

set pGeom = [shape]
Output = pGeom.Envelope.XMin

Google Maps Elevation Web Services (Google)

Thursday, March 25th, 2010

screen-shot-2010-03-24-at-104824-pm

[Editor's note: A free, sans-API key solution from the web mapping giant for showing elevation (point or along custom path) for Google Maps Mashups either in the v3 API directly or separately as a stand-alone web service. And it returns JSON :) Thanks @lagerratrobe!]

Republished from Google.

The Google Elevation web service provides you a simple interface to query locations on the earth for elevation data. Additionally, you may request sampled elevation data along paths, allowing you to calculate elevation changes along routes.

The Elevation service provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values). In those cases where Google does not possess exact elevation measurements at the precise location you request, the service will interpolate and return an averaged value using the four nearest locations.

With the Elevation service, you can develop hiking and biking applications, mobile positioning applications, or low resolution surveying applications.

Check the documentation out over at Google . . .

Wordalizer tag cloud script for InDesign | A Tribute to Wordle (Indiscripts)

Wednesday, March 24th, 2010

_en_01

[Editor's note: Looks like my earlier post on Wordle helped Marc Atret implement tag clouds (word clouds) in InDesign.]

Republished from Indiscripts.

Wordalizer is a word cloud builder for InDesign CS4. Try now the beta version of this experimental script —inpired by the magnificent Wordle web tool created by Jonathan Feinberg.

I began to work on Wordalizer for InDesign in September 2008! Jonathan Feinberg had just launched its brilliant Wordle Java applet and I was highly impressed by the typographical perfection that Wordle could reach in word clouding. I was naively dreaming to operate the same way from the InDesign DOM! Too much confident in my scripting abilities, I still hadn’t realized how powerful the Feinberg’s core algorithm was, until I found this post on “Kelso’s Corner” blog. Feinberg says: “It’s not quite ‘simple bounding box,’ which wouldn’t permit words inside words, or nestling up to ascenders and descenders. It’s full glyph intersection testing, but with a sprinkle of CS applied to make it work at interactive speeds.”

Yes indeed! The hardest part of the whole challenge is in speeding up hit-tests, and you can’t imagine what this Java performance problem looks like when translated into the InDesign JS context! After remaining at a standstill for a long time, I decided to start my script from the beginning again.

Continue reading at Indiscripts . . .

More Multi-touch Links (Random Etc.)

Thursday, March 18th, 2010

[Editor's note: See earlier posts on Google Maps multitouch and AS3 in Flash, Flex, and Air, and 3rd. From Tom Carden, a San Francisco-based programmer and designer at Stamen Design.]

Republished from Random Etc.

Here’s a nice overview of how touch events are modelled in mobile Safari on the iphone. Here’s a student paper detailing some multi-touch code architectures and actual code too.

Here’s a nice article on single point gesture recognition for games, here are lovely simple single stroke and multi-stroke gesture recognisers in javascript. Here’s the corresponding paper. Here’s a paper about modelling gestures using Markov chains.

And here’s a gesture recognition discussion thread featuring some of the above links and many more.

Scriptopedia: JS, AS, and VBA scripts for Create Suite apps

Tuesday, February 9th, 2010

titre

[Editor's note: New script compendium. Some for Illustrator, many for InDesign.]

Republished from Scriptopedia.

Eddy and I are very pleased to announce the release of the scripts library for the Adobe Software and desktop publishing and photography.
Pointing out the dispersion of the scripts over the Internet, we have decided to offer a unique space gathering the best in the automation field.

Javascript, Applescript, VisualBasic or action scripts will be warmly hosted here.

If you want to make part of this adventure and help us filling the base, don’t hesitate and contact us !

We hope you enjoy surfing on this site and using the scripts as much as we had creating Scriptopedia.org.

Thanks in advance and…

Check out Scriptopedia . . .

Time and Again, the Calendar Comes Up Short (Wall Street Journal)

Thursday, January 7th, 2010

na-bd085_numbgu_ns_20091229180832

[Editor's note: If you haven't gotten a 2010 calendar yet, please try my Illustrator script for making your own. Its nifty! Many of my projects last year focused on time and less on mapping. It can be harder to count days than you might think!!!]

Republished from the Wall Street Journal.
By CHARLES FORELLE

Sticklers for Symmetry Lament Imperfections in the 400-Year-Old Gregorian System; Earth’s Inconvenient Orbit

Friday marks the start of another new year, and for a small band of reformers, another missed opportunity.

For the 428th straight year, much of the world will again use the familiar Gregorian calendar. We will suffer the fiscal quarters of varying lengths and the 52 weeks that don’t quite fill the year. We will recite rhymes to recall how many days are in June, and shrug if we are asked whether Halloween is on a weekday.

Almost since Pope Gregory XIII promulgated the new calendar — itself a reform of Julius Caesar’s calendar — in 1582, proposals have bubbled up for something better.

Apostles of efficiency lament that each year needs a fresh wall calendar. The astronomically precise complain that Gregory’s leap-year formula (every four years, except centuries not divisible by 400) is erratic, and a hair off the real year’s length anyway. The financially fixated sigh that next year there will be more shopping days between Thanksgiving and Christmas than this year.

“We have a world-wide consensus about this second-rate calendar that the pope imposed 400 years ago,” Simon Cassidy, a California software engineer and amateur calendar scholar, says by telephone from New Zealand, where he is spending the northern-hemisphere winter.

Creating a calendar is like fitting a lot of round pegs into not quite as many square holes. Western tradition demands a seven-day week. Ancient custom, rooted in moon cycles, calls for a 12-month year. The Earth’s tilted axis produces four seasons. But the Earth, uncooperatively, takes 365 days, plus a tad more, to go once around the sun, and 365 is divisible by none of seven, 12 or four. And thanks to the extra bit of time — about one-fourth of a day — required for a complete orbit, leap years are needed to keep things on track.

Continue reading at the Wall Street Journal . . .

Tag Cloud: In their own words (Wash Post)

Tuesday, December 8th, 2009

[Editor's note: I created these three tag clouds to represent the responses to a national poll conducted for The Washington Post. Respondents chose 1 word to represent the Republican party. The words are all on the same type size scale in each of the 3 clouds. The position of the same words also needed to be consistent between clouds (ie: Palin in the upper left). Obviously the Republicans are on message about being conservative. Created with a custom script in Illustrator. Arranged by hand.]

Republished from The Washington Post. Nov. 30, 2009.

Those taking the poll were asked what word or phrase they would use to describe the Republican Party. The chart below shows all responses cited by two or more people, sized by number of responses.

View larger original at The Washington Post.

gr2009113001885

VBA Field Calculator Tips in ArcMap (Kelso)

Tuesday, November 24th, 2009

fieldcalculator2I’ve been relying on the Advanced logic options in ArcMap’s Field Calculator to wrap up Natural Earth Vector. Because of the diacritical (accent) marks present on many placenames around the world, care must be taken to ensure they don’t get corrupted.

With basic SHP files, I often edit thematic data in Excel and then join it back with the SHP. However, Excel mangles diacritical marks, especially if you’re going cross platform between the Mac and PC. Even when everything is setup right, ArcMap the get Info panel displays ? marks for many diacriticals. The attributes table view shows them correctly, though.

Much of the base data and name attributes are compiled in Adobe Illustrator and exported with MaPublisher using custom scripts I’ve written to take the name from the text that’s been grouped with the feature. This allows contributors who don’t have ArcGIS at home or in the office to take part in the project. Because we often have other attributes (maybe a second name, scale rank, type of feature), I use an “_” underscore character to concatenate these into one string. This string then needs to be parsed back into separate attribute columns.

Note: SHP files use Windows 1252 character encoding. If you’re on a Mac, change your MP export options from “System” to that. If you’re on a PC, you’re already good.

Splitting strings:

In VBA prelogic area (advanced checkmark on):

myString = [ColumnName]
myPosition = InStr(myString , “_”)
myLeft = myPosition – 1

myLen = Len(myString)
myRight = myLen – myPosition
country = Left( myString, myLeft )
provNumber = Right( myString, myRight )

In the field results area: provNumber or country.

Note: If the result is destined for a number formatted column, either caste provNumber as a number or use a temporary holding column that is string formatted, then rerun the field calculator on the number formatted column deriving the value from the temp field. ArcMap with auto-caste for you in that case.

After the jump: Find and replace, counting substrings, hit tests, and changing case.

(more…)

How to Make a US County Thematic Map Using Free Tools (FlowingData)

Friday, November 20th, 2009

[Editor's note: If you don't have an expensive GIS license but still want to make pretty maps, Flowing Data has a tutorial to get you started. They even use ColorBrewer when setting up the data classes!]

Republished from Flowing Data.
Posted by Nathan / Nov 12, 2009.

There are about a million ways to make a choropleth map. You know, the maps that color regions by some metric. The problem is that a lot of solutions require expensive software or have a high learning curve…or both. What if you just want a simple map without all the GIS stuff? In this post, I’ll show you how to make a county-specific choropleth map using only free tools.

The Result

Here’s what we’re after. It’s the most recent unemployment map from last week.

Unemployment in the United States

Step 0. System requirements

Just as a heads up, you’ll need Python installed on your computer. Python comes pre-installed on the Mac. I’m not sure about Windows. If you’re on Linux, well, I’m sure you’re a big enough nerd to already be fluent in Python.

We’re going to make good use of the Python library Beautiful Soup, so you’ll need that too. It’s a super easy, super useful HTML/XML parser that you should come to know and love.

Continue reading at Flowing Data . . .