I'm actually starting to suspect that I can't get a .jpg image from a map created with the UI editor without using a browser. I think I might have to use the API to re-create the map my colleague created so that the map has a layergroupid. An acceptable answer to this question might be to confirm those suspicions.

Original question

I'm a complete beginner with CartoDB.

Somebody in our organisation has created a map in the CartoDB editor (described here), and I need to get a .jpg image from it. The map covers the whole of the country and shows property boundaries. The person who created it is responsible for the styling of the map and for the data the map uses. The datasets are private.

I am writing an API which needs to get aerial images of properties from the CartoDB map, zoomed in so that each image shows a few properties. My API is written in C# and runs on a server. I mention those details to emphasise that there is no browser involved in the interactions with the map, and no Javascript.

The map need only be accessible to trusted entities. The two I can think of are: (1) the person maintaining the map and (2) my code. The code I'll be writing runs in a totally private context on our server. It would therefore be OK for my code to use the api_key when retrieving the .jpg. I can also set a password for the map and use that. (The images retrieved will be stored on our company's server, and those stored images served up to our API users in a completely different security context.) So access to the map is totally private.

I've seen some information about getting .jpg images, but it all seems not to work for me because it requires a layergroupid, which it seems is only available if the map was created through a CartoDB API. Since my map was created using the editor, I don't think there is a layergroupid, and so those methods don't apply.

It might be possible to create the map using the CartoDB API instead of using the editor, so that the map has a layergroupid. This approach has drawbacks though, because my colleague would need to learn a different way to create the maps.

In summary

  • complete beginner with CartoDB
  • map created using CartoDB editor, private datasets
  • no browser, no Javascript
  • method of retrieving .jpg totally private, so could use api_key
  • prefer not to re-create existing editor-created map via CartoDB API


Given those constraints, how can I get the .jpg images I need from the map?

  • What kind of information do you need and for what purpose? This is a very important question because most likely there are much easier solutions to your need than how you are trying to approach it. For example, if you are trying to gather the label info, why not just go to the person who has the original GIS data and get a table from them? If you need a cached tile dataset, then get the GIS data from the originator and use MapBox to create a cached tileset. CartoDB creates the map you see in the browser by overlaying PNGs on top of eachother. You usually have a basemap PNG and data PNG.
    – alexGIS
    Commented Mar 20, 2016 at 22:00
  • @alexGIS The API I'm writing needs to be able to retrieve .jpg images so that it can store them and then serve them up from that local storage, as explained in the third paragraph of the original question: "I am writing an API which needs to get aerial images...". It doesn't need anything else. If there is an easier solution, I'd love to hear it :) Commented Mar 20, 2016 at 22:57
  • Do you own the aerial imagery?
    – alexGIS
    Commented Mar 21, 2016 at 0:15
  • @alexGIS, no, we don't. I'm told we're using the CartoDB base-map images from Nokia HERE Maps Commented Mar 21, 2016 at 0:39
  • Then I'm pretty sure it violates licensing to harvest their aerial imagery, even for internal use.
    – alexGIS
    Commented Mar 21, 2016 at 1:52

1 Answer 1


If you have a Map (named map if it has private data) created already in the Editor, you will be able to find it's template map name in the viz.json file of the map. (Available at the third link in the Publish button under the CartoDB.js title).

Inside your viz.json, look for "named_map" and "name"

type: "namedmap",
order: 1,
options: {
type: "namedmap",
user_name: "iriberri",
maps_api_template: "https://{user}.cartodb.com:443",
sql_api_template: "https://{user}.cartodb.com:443",
tiler_protocol: "http",
tiler_domain: "cartodb.com",
tiler_port: "80",
filter: "mapnik",
named_map: {
name: "tpl_59dc29e0_f006_11e5_9245_0e674067d321",
stat_tag: "59dc29e0-f006-11e5-9245-0e674067d321",
params: {
layer0: 1,
layer1: 1

Now you have your named map name which you can use in the Static Maps API options that allow the template_id (synonym to named map name) directly or you can instantiate it in order to get the layergroup and use this token with the Static Maps API.

Notice that the token will expire after some time, so each time that you need to retrieve an image you'll have to instantiate it. In order to instantiate it, no browser or javascript is required, just:

-H 'Content-Type: application/json' \
-d '' \

So, in short:

If you know the ID of the map created in the Editor, you can request the viz.json file to:


and from the JSON file retrieved, just look into it for the named map object and its name.

There's other question that you posted which is pretty related to my response here and might include extra details also useful: Create a named map with a base map - without Javascript or browser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.