Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Map/coordinate questions

Hello everybody,

I'm trying to create a map in qlik sense. I know how to do it when you already have the coordinates (long and lat), but I don't have it in my data. I only have the names of cities and countries. I've tried it with googlemaps (someone I know tried to help me, but apparently it didn't work in qlik sense, which he found odd). Does anyone know a good way to get the coordinates for the different cities and countries that I have?

Any help would be useful. Have a good day =)

Sincerely,

Betty Habtemariam

Tags (2)
17 Replies
MVP
MVP

Re: Map/coordinate questions

Hi,

Try this sample script

CustomerTable:

LOAD Quantity,

     Customer,

     City

FROM

C:\Users\378025\Desktop\Customer_info.xls

(biff, embedded labels, table is [Sheet1$]);

let noRows = NoOfRows('CustomerTable')-1;

for i=0 to $(noRows)

    let b = peek('City',$(i),'CustomerTable');

 

      

  GeocodeResponse:

  LOAD

  '$(b)' as CustomerCity, 

  ([result/geometry/location/lat]) as latitude,

    ([result/geometry/location/lng]) as longitude

  FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=$(b)&sensor=false] (XmlSimple, Table is [GeocodeResponse]);

next i;

This will get fetch the latitude and longitudes using google maps apis.

Hope this helps you.

Regarsd,

Jagan.

Re: Map/coordinate questions

You can search for those coordinates online.

Please see attached country long and lat

Re: Map/coordinate questions

Hi Jagan,

Does this code work for any language?

Not applicable

Re: Map/coordinate questions

Hi Jagan, I'm going to try this now. I'll get back to you in a bit =)

Not applicable

Re: Map/coordinate questions

Thank you Mika =)

Not applicable

Re: Map/coordinate questions

Okay, so I just hit the load button. I had to fix something first. Qlik Sense wants something calles a lib pathway, so I had to fix that.

Btw, I'm up in well over 15000 GeocodeResponse rows. Is that noemal?

MVP
MVP

Re: Map/coordinate questions

Hi Robert,

I tried it with different language and it is working.  Try this link

http://maps.googleapis.com/maps/api/geocode/xml?address=%E0%AE%9A%E0%AE%BF%E0%AE%99%E0%AF%8D%E0%AE%9...

Regards,

Jagan.

reddys310
Honored Contributor II

Re: Map/coordinate questions

Hi Betty,

If you have the postcodes for the cities you can even use a KML file to plot your map.

MVP
MVP

Re: Map/coordinate questions

HI,

CustomerTable:

LOAD Quantity,

     Customer,

     City

FROM

C:\Users\378025\Desktop\Customer_info.xls

(biff, embedded labels, table is [Sheet1$]);

TempCity:

LOAD

DISTINCT City

RESIDENT CustomerTable;

let noRows = NoOfRows('TempCity')-1;

for i=0 to $(noRows)

    let b = peek('City',$(i),'TempCity');

     

  GeocodeResponse:

  LOAD

  '$(b)' as CustomerCity,

  ([result/geometry/location/lat]) as latitude,

    ([result/geometry/location/lng]) as longitude

  FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=$(b)&sensor=false] (XmlSimple, Table is [GeocodeResponse]);

next i;

DROP TABLE TempCity;

This will reduce the number of iterations.

The best suggestions get the Latitudes and Longitudes in an excel and use it in the Dashboard, instead of everytime getting from GoogleApis.  In some Servers the internet access is restricted, at that time this won't work.

Regards,

Jagan.