Creating maps using SQL queries

Maps generated from database queries are highly useful and easy to create. By using SQL (Structured Query Language) commands, it is possible to select and display only the information that users wish to visualize on a map.

Municipalities of the State of Amazonas

Figure 1 presents the municipalities of the state of Amazonas, extracted from Brazil’s municipal boundary dataset provided by IBGE. The map was generated using a query equivalent to:

“Select all municipalities located in the state of Amazonas.”

In GIS software, the SQL command would be:

SELECT * FROM MUNIC
WHERE HOMEUF = ‘Amazonas’

where MUNIC represents the municipal boundary layer containing all municipalities in Brazil.

Municípios do estado do Amazonas

Figure 1 – Municipalities of the State of Amazonas

Cities with More Than 400,000 Inhabitants

The example shown in Figure 2 illustrates the result of a query such as:

“Select all cities with a population greater than 400,000 inhabitants.”

The SQL command would be:

SELECT * FROM CIDADES
WHERE POPULACAO > 400000

where CIDADES represents the point layer containing all cities in Brazil.

Cidades com mais de 400 mil habitantes

Figure 2 – Cities with More Than 400,000 Inhabitants

Benefits of Query-Based Maps

Maps generated through SQL queries offer several advantages:

  • Display only the information relevant to a specific analysis.
  • Simplify data visualization by filtering unnecessary features.
  • Support decision-making with targeted geographic information.
  • Allow rapid exploration of large geographic databases.
  • Facilitate market, demographic, environmental, and territorial analyses.
  • Enable dynamic map generation based on user-defined criteria.

Common Applications

Query-based maps are frequently used for:

  • Market analysis
  • Sales territory management
  • Population studies
  • Infrastructure planning
  • Environmental monitoring
  • Public administration
  • Business intelligence
  • Logistics and transportation analysis

Modern GIS software packages are designed to simplify the creation of SQL queries, allowing users to build complex selections through graphical interfaces without requiring advanced database knowledge.

Additional Information

More information about creating maps using SQL queries is available in the Gismaps Viewer tutorials:

Thematic Map Creation

Learn how to generate thematic maps based on geographic and statistical data.

Consumption Potential Index (CPI)

Discover how SQL queries can be used to analyze and map Consumption Potential Index (CPI) data for marketing and sales applications.

Query-based maps transform geographic databases into powerful analytical tools, enabling users to visualize exactly the information they need for planning, analysis, and decision-making.