Posts Tagged ‘KML’

Shapefiles, Actionscript 3.0, and Google Maps (Box Shaped World)

Monday, June 8th, 2009

[Editor's note: Tutorial for using the vanrikom classes to read in shapefiles in Flash and Flex AS3 and display them on a Google Maps mashup.]

Republished from the Box Shaped World blog. 28 April 2009.

I’m working an Adobe AIR application and I wanted to be able to have the user select a shapefile, and then parse it to create a KML file.  I didn’t want to have the user be responsible for creating a KML file.  I thought I might try and crack the shapefile enigma since it is a well documented format, but that would have taken time and I suddenly realized I’m not actually a developer :).  Instead, I found this set of Actionscript Classes to parse a shapefile in Flash.  Unfortunately, I didn’t find a very good tutorial on how to work with the classes.  The example is a little confusing (at least for me) and also uses a far file.  I’d never heard of far compressed files.  So I took the classes and created my own parser.  I thought I would post a tutorial on how to use these shapefile classes in conjunction with AIR and the Google Maps API for flash.  This technique would work with flex as well, I just didn’t want to have to write the code to upload a file.  I presume a few things with this.  The shapefile you are using for this should already have a geographic projection (e.g. latitude and longitude Geographic NAD 83).  In order to use the Google Maps API with AIR, you need a URL with a key associated with it.  Below are two zipfiles available for download.  The testfile.zip is the shapefile I was using.  The vanrikom.zip is the downloaded actionscript classes from the Google Code repository.  I had trouble downloading the using an svn so I did it manually.  I’ll save you the time by making it available here…unless the original author asks me to remove them.  There are parts that I find confusing with the way the reader was set up.  For some reason polyline inherits from polygon.  Intuitively to me it should be the other way around…but like I said, I’m not a developer.

This was all done using FlashDevelop and the Flex SDK 3.  There are 4 custom classes in addition to the mxml file.  Each are shown here.

Continue reading at Box Shaped World . . .

IndieProjector for KML and Shapefiles (IndieMapper)

Monday, June 1st, 2009

indieprojector1

indieprojector3

indieprojector2

[Editor's note: The brilliant folks at AxisMaps have done it again with this free online tool for reprojecting KML and shapefiles.]

Republished from Axis Maps / IndieMapper.

Indieprojector is a free web service that re-projects digital map files and converts them to SVG for use in vector graphics editing software. Map projections are an essential part of map making but we found the existing tools to be too expensive, inflexible or complicated. Indieprojector is the smarter, easier, more elegant way to reproject and convert geographic data. It’s a preview of our indiemapper technology that will bring map-making into the 21st century using web-services and a realtime visual approach to cartographic design.

Read more and watch demo screencast . . .

Go directly to IndieProjector to reproject your KML and shapefiles . . .

Noncontiguous Area Cartograms (IndieMaps)

Monday, March 2nd, 2009

[Editor's note: Zach Johnson promotes his Actionscript 3 class for producing non-continuous cartograms and gives background on why these are better (and easier to construct) than Gaster-Newman continuous cartograms.]

Excerpted from IndieMaps blog by Zach Johnson.
View full blog post from Dec. 4, 2008.

Fully contiguous cartograms have stretched and distorted borders but perfectly maintained topologies. Like the Gastner-Newman diffusion-based cartograms we see all over the place. Though all sorts of cartogram designs have been produced, those with perfect topology preservation (fully contiguous cartograms) receive the majority of academic and popular press attention.

< snip >

Judy Olson (Wisconsin Geography alum natch) wrote the only academic article to focus specifically on this cartogram symbology in 1976. She believed noncontiguous cartograms held three potential advantages over contiguous cartograms (I’ve three more below):

  1. “the empty areas, or gaps, between observation units are meaningful representations of discrepancies of values, these discrepancies generally being a major reason for constructing a cartogram”
  2. production of noncontiguous cartograms involves “only the discrete units for which information is available and only the lines which can be accurately relocated on the original map appear on the noncontiguous cartogram”
  3. because of perfect shape preservation, “recognition of the units represented is relatively uncomplicated for the reader”

Despite these inherent advantages (along with ease of production), all the early value-by-area cartograms I’ve seen maintain contiguity. Some took the radical step of abstracting features to geometric primitives, like Levasseur’s early French examples (which may not have been cartograms) and Erwin Raisz’s early American “rectangular statistical cartograms”. But in many ways the noncontiguous design is the more radical cartogram, as it actually breaks the basemap apart — rather than skewing shared borders it abandons them.

my [his] AS3 classes

Olson outlines a technique — the projector method — for manually producing such cartograms. A projector capable of precise numeric reduction/enlargement was required, but not much else, and accurate cartograms could be produced in minutes. A scaling factor was calculated for each enumeration unit, the projector was set to this value, and the projected borders were traced, keeping units centered on their original centers.

My [his] AS3 NoncontiguousCartogram class works similarly. It takes an array of objects containing geometry and attribute properties and creates a noncontiguous cartogram. I include methods for creating the input array from a shapefile/dbf combo, but using KML, WKT, or geoJSON representations wouldn’t be too hard. Methods are included for projecting this lat/long linework (to Lambert’s Conformal Conic projection at least). The NoncontiguousCartogram class draws the input geography, figures the area of each feature, and scales figures according to their density in the chosen thematic variable.

It’s all good/in ActionScript 3, so can be used in Flash or Flex. The zip distribution includes the following:

  • the main NoncontiguousCartogram.as class
  • two example applications and the data needed to run them
  • utility classes, including some that make creating cartograms from shp/dbf input quite easy
  • Edwin Van Rijkom’s SHP and DBF libraries, which are used to load the shapefiles in both of the included examples
  • Keith Peters’ MinimalComps AS3 component library, for the components used in one of the examples
  • Grant Skinner’s gTween class, which is required by the NoncontiguousCartogram class for tween transitions

Browse all the above or download the zip.

<snip>

more advantages

In my thesis research last spring, noncontiguous cartograms performed quite well: subjects rated them highly on aesthetics and could locate and estimate the areas of features with relatively high accuracy. I would add the following to Olson’s list of noncontiguous cartogram advantages.

  1. Olson concentrates on the perfect shape preservation of noncontiguous cartograms. The form (well, those with units centered on the original enumeration unit centroids, as in Olson’s projector method) also perfectly preserves the location of the features on the resultant transformed cartogram. Not only are features easier to recognize, but locations within the transformed units can be accurately located as well (cities or mountain ranges from the original geography can be accurately plotted on the transformed cartogram).
  2. Because units are separate on the transformed cartogram, their figure-ground is increased and areas of features can therefore be more accurately estimated.
  3. Many cartogram designs (including most manual cartograms and the Gastner-Newman-produced cartograms) sacrifice some accuracy for shape recognition. This is a defensible tradeoff, especially as area estimation is notoriously inaccurate and nonlinear. Yet it’s a tradeoff that noncontigous cartograms need not make, as they can always perfectly represent the data with relative areas without sacrificing shape preservation.

Thus, noncontiguous cartograms seem to excel at the cartogram’s two main map-reading tasks: shape recognition and area estimation. This is mediated somewhat by the chief advantage of contiguous cartograms: compactness. Because no space is created between enumeration units, contiguous cartogram enumeration units can be larger than those on noncontiguous cartograms, all other things equal. The increased size on contiguous cartograms may improves their legibility.

Read the full entry over at Indie Maps . . .

KML to Shapefile File Conversion (Zonum)

Friday, December 12th, 2008

[Editor’s note: Useful free tool for converting KML files to Shapefile for use in the GIS. Thanks Mary Kate!]

Republished from Zonum Solutions. Kml2shp file conversion

Need of transferring Google Earth Data to a GIS? Kml2shp transforms KML files into ESRI Shapefiles.

Download. Windows program. No Mac version.

The KML file could contain Points, Paths and Polygons. When creating SHP files the information is separated into thematic layers.

For each shapefile (shp), an attributes table (dbf) and index file (shx) are created.

The kml to shp conversion consists of three steps:

1) Open KML file
2) Choose Shape Type
3) Select output Shapefile name

Optionally, you can change from WGS84 to a local datum and from Lat/Lon to UTM.

Also, Kml2shp can export to AutoCAD (DXF) and GPS (GPX)

kml2Shp is a beta freeware tool. This program doesn’t need to be
installed, just unzip it and run it.

kml2shp.zip contains the executable file (kml2shp.exe) and some bpl files. If you receive a message error about missing bpl files, come back here and get them.

DOWNLOAD

ArcGIS 9.3 Now Exports Geo PDF Maps (ESRI)

Monday, October 20th, 2008

Adobe® Acrobat® and Adobe Reader® version 9 support a new version of PDF that allows for encoding of map coordinate system and georeference information inside the PDF file.

[Update 2010 August 13: To make this work in ArcMap 9.3 you need to apply the ArcGIS (Desktop, Engine, Server) 9.3 Map Export Patch. That installs two DLLs that allow the Export Map Georeference Information checkbox. Without that, you’re maps might have layers, but no coordinate system.]

This news release was in the summer 2008 issue (read) of the Arc user magazine but it came up last week at NACIS. Why is this better than other PDF solutions like TerraGo? It is completely free to both the cartographer and map reader and requires basic Adobe Acrobat (no plugins to download). ESRI and Adobe collaborated for a year on these PDF geospatial capabilities enhancements.

It works on both Mac and PC while other solutions are PC only. It is not full featured, though feature attributes and coordinates are accessible in Acrobat. But nifty tidbit: with Acrobat Pro you can import supplementary geo data into an existing geo PDF, even if it is in a different projection, and it will overlay onto the map. Might turn out to be a quick and dirty reprojection trick for those without ArcMap.

Most information below directly from ESRI promotional material.

ArcGIS 9.3 has new and improved functionality for exporting maps to Adobe PDF including map layers and location information for end users with Adobe Acrobat 9 or Reader 9 software. These enhancements are available as a freely downloadable patch for ArcGIS Desktop, ArcGIS Server, and ArcGIS Engine. This patch enables ArcGIS Desktop, Engine, and Server applications to export georeferenced PDF files.

When a georeferenced PDF is opened in a compatible viewer, such as Adobe Reader 9, the user can access geospatial functions like coordinate readout and find XY.  This patch enables ArcGIS Desktop, Engine, and Server applications to export georeferenced PDF files.

Check out this video demonstration from ESRI TV:

Using Google Maps to Visualize ArcGIS Data & Services (Google Geo Dev. Blog)

Wednesday, September 3rd, 2008

[Editor's note: This blog joint blog post from ESRI and Google has examples on how to integrate the new 9.4 features with Google Maps Mashups. This includes all the power of GIS geo-processing leveraged into the Mashup environment. I hope this trend continues with the promised release of a Flash/Flex API for ArcGIS.]

Reprinted from Google Geo Developers Blog. Tuesday, August 12, 2008

Hi, I’m Sterling Quinn and I work on the development team for server-based GIS technologies at ESRI in Redlands, California. We’re happy to report that ESRI software users can now expose their GIS in Google Maps through the recently-released ArcGIS JavaScript Extension for the Google Maps API. The extension is built on the Google Maps API and is designed to communicate with ArcGIS Server, ESRI’s product for serving GIS functionality on the Web.

The ArcGIS JavaScript Extension for the Google Maps API allows you to maintain the user-friendly front end of Google Maps while tapping into an advanced GIS on the back end. You can use the extension to display your own maps on top of Google’s, query features in your database and display them on the map, or expose tasks that run GIS analysis models on the server. You can display your results using the Google Maps API’s native graphics engine and info windows.

To learn how to use the ArcGIS JavaScript Extension for the Google Maps API, use the online SDK, which contains basic concepts, an API reference, and examples of how to create custom maps and Mapplets. The examples contain detailed descriptions on how to do things like adding an ArcGIS Server map type button,displaying query results as KML, or running a task on the server to return a route and elevation profile.

Following are some quick links to example Mapplets built with the ArcGIS JavaScript Extension for the Google Maps API. For those of you who don’t know, Mapplets are mini applications that you can add to Google Maps in the “My Maps” tab and are nifty because a user can enable multiple Mapplets at a time.

Cached Map ServiceDisplays an ArcGIS tiled map service over the Google base map.

Census Block QueryRetrieves US Census data from an ArcGIS map service at a point you click and displays it in a series of charts created with the Google Chart API.

Message in a BottleUses an ArcGIS geoprocessing service to tell you where a bottle would drift if you dropped it in the ocean.

Service Area AnalysisUses an ArcGIS geoprocessing service to display drive time polygons from a point you click.

GPS Kit – New software app for iPhone 3G (Kelso)

Sunday, August 17th, 2008

 

Garafa published GPS Kit for the iPhone 3G on August 14th for $10. YouTube demonstration above from Garafa. I’ve spent the weekend experimenting with the app and the accuracy seems comparable to RunKeeper and iTrail which I reviewed last week. However, GPS Kit has better features, though by the time you read this iTrail will have nearly caught up. GPS Kit meets 10 of my 22 criteria for GPS on the iPhone, the same as iTrail but with GPS Kit having a higher price point but with slightly nicer package. 

The three main functions of GPS Kit are:

  • Dashboard
    • See real time information like latitude, longitude, speed, altitude, heading (cardinal direction, degree), and distance
    • User modifiable statistics (including averages) and units
  • Tracks
    • Intelligent data collection intervals: If you move fast, more points, if slow less points.
    • Save your route
    • View on iPhone in app
    • Share with anyone via email in Google Earth (KML) or Google Maps
  • Waypoints
    • Save points of interest 
    • See how far you are from each waypoint. 
    • View on iPhone in app
    • Share with anyone via email in Google Earth (KML) or Google Maps

Features I wish GPS Kit had:

  • Tracks
    • Better way to see live-GPS route tracking (now a several step process)
    • Resume dialog on restart of app after taking call or other interruption ala Distance Meter
    • Screen lock while recording tracks ala iTrail
    • View on live Google map (now just blank screen?) with both satellite, hybrid, and map tiles
    • Save with KML the stats that are currently displayed on screen for that segment of track
    • In KML record GPS accuracy (eg: accurate to 10m, 310m).
    • KML that does not have 3 nodes at each data point
    • Provide altitude readjustment by matching lat/long against SRTM elevations
    • Import tracks via KML or GPX
  • Waypoints
    • View on live Google map (now just blank screen?) with both satellite, hybrid, and map tiles
    • Set custom icon with preset of common icons
    • Import waypoints via KML or GPX
    • Attach photos to location (location is created on capture of photo)
    • See photo waypoints on the map as icons (multiple, not just active photo waypoint)
    • Click on the photo icon in map view get a big view of the photo and edit text description
    • Attach a longer text description to each location, not just the name

Screenshots of GPS Kit:

Other applications on the App Store that provide portions of similar functionality and their prices:

  • iTrail @ $3- in app map of route, plotting of statistics; has a screen lock while recording. Export to GPX and KML. No waypoint support (coming in version 1.3). Read my review.
  • RunKeeper @ $10- Geared more towards fitness activities with stats like “pace”. Needs to upload data to web service (free) to see route on map. Read my review.
  • GPS Tracker @ free – real-time tracking service including lat, long, altitude, speed, heading, and accuracy. Can export to CVS and KML. Requires web service to record and see on map.
  • gSpot @ $2 –  no privacy concerns (not published online for anyone to see as you move with the app on): lat, long, altitude, speed, heading, and accuracy. Can share waypoints via email. Can display waypoints in the iPhone’s mapping application. 
  • PathTracker @ $1 – real time map showing route/track; distance, time, average speed, current location and altitude; save your path and export in GPX and KML. Available in many different languages including Chinese, French, and Spanish.
  • gps Compass @ $2 – real time stats that are user modifiable; multiple languages including German and Japanese. No map.
  • Speedster GPS @ $1 – speed and altitude in real time with history of pervious data points. No map.
  • Distance Meter @ $3- distance, speed, and pace tracker. No map. Altitude and XY shown for current location only.
  • Geopher Lite @ $2 – distance and heading to waypoint. No map. Ability to turn GPS off in certain functions to save battery. 
  • OverHere @ $1 – email waypoint (current location). No map.
  • Altitude @ $1 – altitude with accuracy (but is it Z accuracy or XY accuracy?). No map.
  • Speed @ free – real time speedometer. No map.

All of these applications require an iPhone 3G with GPS for best performance. 

References: 

iPhone Chat.org and iPhoneFreakz.com.

Virginia Road Work Plans Are Halted (Mashup)

Saturday, June 21st, 2008

va transport road funding cuts

(Editor: I published this mashup for The Washington Post on Thursday, updated Friday. View here. It features custom Wash.-Post-style map markers, KML integration for the linear features, and a table listing out the same cut and delayed projects below the map in text format. The entries in the table are hyperlinked back into the map where a more detailed listing on each entry is found in the info window.)

The Commonwealth Transportation Board voted Thursday to approve a six-year spending plan that cuts hundreds of projects statewide. Below is a sampling of key projects that will be delayed or eliminated. Related article here.

Reporting by Robert Thomson; Interactive by Nathaniel V. Kelso — The Washington Post. Updated June 20, 2008

Newsflash! ESRI to best Google Maps with Mashup Capability

Monday, May 12th, 2008

(Reprinted from flex888.com. View original post.)

Finally, GeoWeb is Complete and Born

Posted by Moxie | March 19, 2008 .

What’s is the best RIA application ever created? If your answer is something aroundFlex or Flash, then it’ll be wrong answer. The right answer is Google Map. It’s Google Map makes AJAX known and RIA a reality. Google even goes above and beyond claimed the term “GeoWeb“. However, up till now, Google Map is still just the best client, the visualization end, of GeoWeb. The “Geo” part of GeoWeb was missing.

Yesterday, ESRI, the shy, but true and real “Geo” dude behind all, I mean ALL, the web map buzz and technologies, released its very own JavaScript API and REST based Geo Process services to the world. The GeoWeb is finally complete and born.

The JavaScript API has three parts, the ESRI JavaScript API, the Google Map extension, the Virtual Earth extension. That means you can use the top three GeoWeb clients with this simple API to do the real “Geo” things.

What is the “Geo” things and why it’s a big deal to GeoWeb?

Well, everyone and his/her grandma knows what Google Map does, plans the trip and shows locations. What’s the most mashed up platform? Google Map. What 99% Google Map mashup applications do? Put pins (markers) on the map? But what if we want to ask some questions beyond the pushpins:

  • Within 5 minutes driving time, show me the areas that I can reach. Don’t fool me with a circle. That is cheating. Because there might be highway, service street, or river among the 5 minutes driving range. The area you can cover by driving is a irregular polygon. But how do you get that polygon drawn on the map to show the 5 minute driving range?
  • Three of my friends want to meet for lunch. We want to meet at a Starbucks where everybody has the least driving time to get there. Fair enough? But how do you quickly give me that Starbucks location and provide driving direction for each of us.

The questions can go on and on. How these questions are answered? Through a thing called Geoprocessing, which is provided by the technology called GIS (geographic information system). But why you’ve never heard of it and it’s not well known in the Web 2.0 space? That’s because it’s a very hard nut to crack and only a few dudes know how to do it inside out. ESRI is the one does it the best, and now, it gets everything figured it out. The whole web can have it.

If I tell you, with three lines of JavaScript codes, plus some regular JavaScript programming you can easily answer the above question visually on either ESRI map, Google Map or Earth Map. Do you believe me?

You don’t have to because I’ll show you how.

First Line:

    var map = new esri.Map(“mapDiv”, { extent: startExtent });

Looks familiar, isn’t it. Indeed, it’s just like Google Map or Virtual Earth API.

Second Line:

    var streetMap = new esri.layers.ArcGISTiledMapServiceLayer
(“http://server.arcgisonline.com/ArcGIS/rest/services/
ESRI_StreetMap_World_2D/MapServer”);

Something new here. Well, if you head to ArcGIS Online, a free gwoweb resource from ESRI, you would find out there are lots of good free base maps you can choose. Or, you can use any map published to a ArcGIS Server. It’s long story here for those map publishing goodies, I’ll tell you later, piece by piece. But just you know this line of code gives you a whole big world of maps to works with. Just remembering that is enough for now.

Third Line:

var gp = new esri.tasks.Geoprocessor
(“http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/
Network/ESRI_DriveTime_US/ GPServer/CreateDriveTimePolygons”);

This is “Geo” part of the GeoWeb. One line, it consumes a geoprocess, in this case, a services called CreateDriveTimePolygons. This geoprocess called is actually via REST API (as the URL reveals) . The returned result can be in JSON, KML or XML. That means you really don’t have to use this JavaScript API. As matter of fact, I do have Perl or PHPexamples consume the very same gepprocess, but that’ll be another post.

The rest code is really just parse the result and draw the polygon on the map. If you know Google Map API, there are no surprises there.

The following is the true GeoWeb application I’ve introduced to you. You can zoom in to any city just like you would do with gmap (scrolling mouse, drag the map, etc.). Then click the map. The 1, 3 and 5 minutes driving time polygon will be shown.

Click Here to Run the Application (view source for detail code).

I will post another example to solve that other problem using Flex. Stay tuned.

KML: Now An Open OGC Standard For Sharing GeoData

Wednesday, April 16th, 2008

(Reprinted from Google’s Lat-Long Blog, view here)

Google Earth and other similar tools have done much to bring mapping into the digital age. Nowadays we all take for granted that you can easily go online and map search results for pizza in your zip code or zoom into satellite imagery of a small town on the other side of the world.

However, the internet is about much more than just searching and viewing information. It’s also about publishing. It wouldn’t be what it is today without blogs, wikis, social networking sites, and other forms of user-generated content. The web is what makes all of this possible, and HTML is what makes the web possible — a standard format that enables any web browser to view any web page. HTML’s standardization was a very powerful thing. Rather than being locked up in a proprietary format, or only viewable using one specific vendor’s product, web pages can be viewed and shared without encumbrance, for free.

This brings me to today’s wonderful news: KML is now an international standard!

Continue reading at Google.com . . .