Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Creating a kml file

by RFMonk (Acolyte)
on Dec 19, 2012 at 14:23 UTC ( #1009569=perlquestion: print w/ replies, xml ) Need Help??
RFMonk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

First of all, I am new to Perl but not so new to programming. Anyway I am loving Perl more than Java or Pascal... Is fun.

Well, to the point:

I wanna do the following script for my job:

I analyze metrics,KPIs and all that telecom stuff.

So, I want to convert all the data into a KML file to be able to see it in Google earth.

For example, I got in Melbourne 3 Base station and around them I have 50% of drops calls. so this data I have it in Excel but I am trying to make a script to be able to see it from google earth in a Choropleth Map (http://en.wikipedia.org/wiki/Choropleth_map)

So, I am trying to use Geo::KML::PolyMap but when I am running my code the following error comes up:

"Not an ARRAY reference at C:\Myperl\perl\site\lib\Geo\KML\PolyMap.pm"

So it can be a bug or I am doing something wrong.

Finnaly, the fact is that I am basically copying and pasting the code from CPAN and Testing/running to see if it works.

The code is the following:

#!/usr/bin/perl # Tratando de crear un programa que lea, realices unas condiciones y c +rea un nuevo archivo xlsx con el resultado use strict; use warnings; system qw"cls"; use Geo::KML::PolyMap qw(generate_kml_file generate_kmz_file); my $poly = "((144.9659,-37.8136),(144.9577,-37.81864),(144.9707,-37.81 +46),(144.9659,-37.8136))"; my $data = 'DCR '; my $entities = { data => $data, polygon => $poly}; # Clusters "Total Population" data for "Foobar City" in $entities into + 5 bins; # renders using colors from $startcolor to $endcolor; # generates a legend; renders output to file handle passed in $kmz_fil +ehandle generate_kmz_file(entities => $entities, placename => "Foobar City", data_desc => "Total Population", nbins => 5, kmzfh => 'C:\Myperl\data\maptest.kml', startcolor => "FFFF0000", endcolor => "FF00FF00"); # As above, but without a legend generate_kml_file(entities => $entities, placename => "Foobar City", data_desc => "Total Population", nbins => 5, kmlfh => 'C:\Myperl\data\maptest.kml', startcolor => "FFFF0000", endcolor => "FF00FF00");
Thanks you!!!!!!!!!!!!!!!!!!!!!!!

Comment on Creating a kml file
Download Code
Re: Creating a kml file
by tinita (Parson) on Dec 19, 2012 at 15:14 UTC
    "Not an ARRAY reference at C:\Myperl\perl\site\lib\Geo\KML\PolyMap.pm"
    oh strange, it doesn't tell you the line number where the error occurred?
      does not, No code line!

        When I ran your code here is what the error message was:

        Not an ARRAY reference at C:/strawberry/perl/site/lib/Geo/KML/PolyMap.pm line 362.
Re: Creating a kml file
by roboticus (Canon) on Dec 19, 2012 at 15:55 UTC

    RFMonk:

    I just looked over the docs for Geo::KML::PolyMap. It looks like the problem is that you're passing in a single entity, rather than an array of entities. The docs are easy to interpret, because it shows a variably named $entity being created, and then later it shows a variable $entities being the parameter. It's easy to miss the singular to plural form. So it may work if you simply change $entities to [ $entities ] in the call--unless it's going to require more than one entity.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      The OP also defines $data in the $entity as a string where the documentation specifies it should be a number.

      Thank you very much!!!! Did not see that detail of plural and singular in the variables. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1009569]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-07-23 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (137 votes), past polls