# How do you create an array to store geolocation which can appear on a map?

**URL:** <https://discourse.processing.org/t/how-do-you-create-an-array-to-store-geolocation-which-can-appear-on-a-map/20062>\
**Category:** Coding Questions\
**Created:** [April 23, 2020, 12:08pm UTC](https://discourse.processing.org/t/how-do-you-create-an-array-to-store-geolocation-which-can-appear-on-a-map/20062 "2020-04-23T12:08:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stage1](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Stage1](https://discourse.processing.org/u/Stage1)\
**Post date:** [April 23, 2020, 12:08pm UTC](https://discourse.processing.org/t/how-do-you-create-an-array-to-store-geolocation-which-can-appear-on-a-map/20062/1 "2020-04-23T12:08:21Z")

</div>

I have a csv file which states the names of cities of UK that have different geolocations for each cities. Considering theres over 10 cities i would like to store these cities into an array and then have them mapped onto each city area of the UK map.

How do i create an array that would read each city along with the latitude and longitude in order to have them mapped onto the UK map and when they are mapped i would want each city location to be clickable so it displays a text.

I have three different screens for different years of the cities, so when i click each screen it shows different data and this is where it gets confusing as i have no idea of how and where i would need to put it.

I can send the code over by PM for anyone who can assist me with it.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 23, 2020, 12:54pm UTC](https://discourse.processing.org/t/how-do-you-create-an-array-to-store-geolocation-which-can-appear-on-a-map/20062/2 "2020-04-23T12:54:08Z")

</div>

Hello!

Okay, you can load csv data with loadStrings, then for loop and split()

You can display geo data with a library unfolding maps, search it here on the forum  
see [https://discourse.processing.org/search?q=unfolding%20maps](https://discourse.processing.org/search?q=unfolding%20maps)

to show different years: let’s say you press 1 for 2015, 2 for 2016 and 3 for 2017, set a String in keyPressed() to these years and evaluate in draw().

Chrisir

**Example Sketch**

```auto

String year = "2015"; 

void setup() {
  size (600, 600);
}

void draw() {
  background(17);

  switch (year) {

  case "2015":
    background(17); 
    fill(255); 
    text("Year 15...", 100, 100);
    break; 

  case "2016":
    background(177);
    fill(0); 
    text("Year 16...", 100, 100);
    break; 

  case "2017":
    background(17);
    fill(255); 
    text("Year 17...", 100, 100);
    break;
  }//switch
}//func 

void keyPressed() {
  switch (key) {
  case'1':
    year="2015";
    break;

  case'2':
    year="2016";
    break;

  case'3':
    year="2017";
    break;
  }//switch
  //
}//func
//

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 3, 2020, 6:35pm UTC](https://discourse.processing.org/t/how-do-you-create-an-array-to-store-geolocation-which-can-appear-on-a-map/20062/3 "2020-05-03T18:35:59Z")

</div>

> [@Stage1](#):
>
> How do i create an array that would read each city along with the latitude and longitude

You can use loadStrings or loadTable.

> **[loadStrings() / Reference](https://processing.org/reference/loadStrings_.html)**
>
> Reads the contents of a file and creates a String array of its individual lines. If the name of the file is used as the parameter, as in the above example, the file must be loaded in the sketch's "dat…

> **[loadTable() / Reference](https://processing.org/reference/loadTable_.html)**
>
> Reads the contents of a file or URL and creates a Table object with its values. If a file is specified, it must be located in the sketch's "data" folder. The filename parameter can also be a URL to a …

The [Table](https://processing.org/reference/Table.html) object is a bit more complex to work with, but it is designed to work with csv format data of different column data types. It will let you store names, lat/long floats, and other metadata in each TableRow so that you can loop over them for display or look them up by index or name value.
