# How to project a coordinate system on an image?

**URL:** <https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467>\
**Category:** Visualization\
**Created:** [March 6, 2022, 9:47am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467 "2022-03-06T09:47:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![matic\_lauko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matic_lauko/32/27770_2.png) [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Post date:** [March 6, 2022, 9:47am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/1 "2022-03-06T09:47:24Z")

</div>

Hello, I’m trying to create a graph of some cities in Europe, I have tried guessing where cities would be but without much accuracy, and got an idea to just use an image and coordinate system to get direct coordinates and use those. But, haven’t found any package to do that.  
Also, could I put an image as a background image of a graph using GraphMakie, or Graphs?  
Thank you.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 6, 2022, 8:26pm UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/2 "2022-03-06T20:26:32Z")

</div>

Like this?

```julia
using GMT
city_coords = [12.50 41.88; -9.13 38.72; -3.68 40.44; 2.32 48.85; 23.74 37.97; 16.36 48.21; 10.19 36.79];
city_names = ["Rome", "Lisbon", "Madrid", "Lutecia", "Athens", "Vienna", "Tunis"];
cities = mat2ds(city_coords, city_names);

# The image will be downloaded automatically
grdimage("@earth_day_03m", region=(-10,28,34,51), proj=:guess)

plot!(cities, connection="p", lw=1, lc=:yellow, marker=:circ, ms=0.2, mc=:white)
text!(cities, offset=0.3, font=(10,:red), show=true)

```

 ![GMTjl_tmp](https://global.discourse-cdn.com/julialang/original/3X/4/0/4061b6f3c9183e4a67e849632deb79190ef17d93.jpeg)

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [March 7, 2022, 5:58pm UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/3 "2022-03-07T17:58:39Z")

</div>

Awesome!

GMT syntax seems to be much more julian than before.

Cheers!

---

<div class="post-metadata">

**Author:** ![matic\_lauko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matic_lauko/32/27770_2.png) [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Post date:** [March 8, 2022, 5:07am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/4 "2022-03-08T05:07:01Z")

</div>

Wow, that is great, but is there a way to make a map look like a rectangle? and to export coordinates, to be able to use them as a game. Maybe even get coordinates out as an array.  
But, even if not it still makes making a game much easier. Really thank you.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 8, 2022, 6:44pm UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/5 "2022-03-08T18:44:51Z")

</div>

If you want a rectangular map use a cylindrical projection or remove the `proj=:guess` option. Now regarding exporting coordinates, what coordinates? Those of the cities? They were _imported_ via the `city_coords` variable. Nothing to export here.

---

<div class="post-metadata">

**Author:** ![matic\_lauko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matic_lauko/32/27770_2.png) [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Post date:** [March 8, 2022, 8:48pm UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/6 "2022-03-08T20:48:16Z")

</div>

Thanks, can I use the package with Graphs.jl, or somehow change the coordinates to the ones that I can use in the normal coordinate plane.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 8, 2022, 9:23pm UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/7 "2022-03-08T21:23:03Z")

</div>

> [@matic\_lauko](#):
>
> can I use the package with Graphs.jl

Sorry, don’t know and also don’t what Graphs.jl outputs.

> [@matic\_lauko](#):
>
> change the coordinates to the ones that I can use in the normal coordinate plane.

What is the _normal coordinate plane_? You mentioned cities and one of the most _normal_ coordinates for them are the geographical coordinates, which is what was used in the example.

---

<div class="post-metadata">

**Author:** ![matic\_lauko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matic_lauko/32/27770_2.png) [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Post date:** [March 9, 2022, 4:57am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/8 "2022-03-09T04:57:12Z")

</div>

Just one more question(I think), about GMT.jl. How do I install the GMT file that it works with, as the website they are linking to doesn’t exist anymore?  
And sorry for not asking sooner, but how did you get coordinates for `city_coords`

---

<div class="post-metadata">

**Author:** ![matic\_lauko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matic_lauko/32/27770_2.png) [@matic\_lauko](https://discourse.julialang.org/u/matic_lauko)\
**Post date:** [March 9, 2022, 5:01am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/9 "2022-03-09T05:01:48Z")

</div>

I had opened an issue on GitHub.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 9, 2022, 10:16am UTC](https://discourse.julialang.org/t/how-to-project-a-coordinate-system-on-an-image/77467/10 "2022-03-09T10:16:47Z")

</div>

Don’t know what links you followed but on the [official GMT site](https://www.generic-mapping-tools.org/) you only have to follow the `downloads` tab.  
But, specially on Windows, you only have to do `] add GMT` and get everything. The wrapper and the lib.

Regarding the coordinates, I used a few from [https://github.com/joa-quim/mirone/blob/master/data/wcity\_major.dat](https://github.com/joa-quim/mirone/blob/master/data/wcity_major.dat) but you can easily get them from GoogleEarth.
