Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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 (

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\"

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!!!!!!!!!!!!!!!!!!!!!!!

Replies are listed 'Best First'.
Re: Creating a kml file
by roboticus (Chancellor) on Dec 19, 2012 at 15:55 UTC


    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.


    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!
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\"
    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/ line 362.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1009569]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-03-17 06:50 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (223 votes). Check out past polls.