Note: This post has been written in collaboration with Antonio F. Rodríguez Pascual Deputy Assistant Director of the Spanish Centre for Geographical Information.
National Mapping Agencies are organizations with lots of data to offer to citizens and organizations like thematic data but also Reference Data (data used to georeference other information) generally known as basemaps. They are great producers of data and do their best to put it into people's hands normally using two approaches: direct data download or standard services. Standard services are the preferred way to publish rendered maps using the well known Web Map Service (WMS) which works for both for vector maps and to serve imagery. The tiled version of this service is called Web Map Tiled Service (WMTS) and its use is becoming also more popular as client applications implement it.
With CartoDB it is straight forward to add a WMS/WMTS service as a basemap. For example we can take the Spanish official 1:25 000 WMTS base map by the IGN the Spanish National Mapping Agency (Instituto Geográfico Nacional) and add it to CartoDB simply by putting the url
http://www.ign.es/wmts/ign-base on the WMS/WMTS section of the custom base map dialog.
There are plenty of great services to be used as basemaps including this map created to compare current Madrid neighborhoods with the shape of the city in 1875.
Another approach is directly using NMA data with your CartoDB account. Permission to use this data will vary depending on the license of the datasets from public domain to applying some restrictions like non commercial use. Always check your dataset license!. If the dataset is directly offered on a format suitable by CartoDB (like a zipped shapefile) you can create a Synced Dataset that will be checked periodically and updated automatically if needed. Unfortunately data is not always directly available because you may need to complete a form to download it or you need to process it before uploading to your account.
Regarding data licensing there are some NMAs who are publishing their data under open conditions. We usually understand Open Data as data under CC-BY CC-BY-SA and similar licenses. It is not easy to know what the situation is in each country; the best effort made in this direction is the annually updated web page by the Open Knowledge Foundation about Open Data in the world which includes a very interesting section about maps.
For example Canada United States Mexico Denmark Norway and recently Spain have partially or totally opened their official cartography. In the case of Spain the National Geographic Institute has defined in December 2015 all its digital data products as Open Data and it's publishing them under a CC-BY 4.0 or equivalent license. It is generally assumed worldwide that this is a good idea because open geospatial data acts as a development engine. However sometimes NMAs are obliged to follow a restrictive legal framework and/or a business model based on self-financing.
In any case it is important to stress that it is essential to maintain attribution in case of reuse others geographic data for recognizing the original authorship and copyright of the data you are using. This is the first requirement of any data producer. On the other hand it is also useful to take advantage of the reliability and prestige of the base data you are using in your product.
To do this in CartoDB remember to fill the Attribution box on your tables' metadata so your maps are correctly attributing your sources. In the case of data coming from CartoDB Data Library this is automatically set up for you.
Happy open data mapping!