You are on page 1of 26

Mapanet™

www.mapanet.eu

PRODUCT SPECIFICATIONS 13 Jul 2019

Thank you for evaluating Mapanet products, we appreciate your business. Hereafter
you will find technical information of our datasets and how to import the data in
your application.

The use Mapanet data is subject to our terms and conditions, by downloading any
data implies that you read and accepted the terms and conditions in the license
document.

DATASETS
ADMINISTRATIVE REGIONS

This file contains the primary four administrative divisions (province down to district
level) of every country and territory in the respective available languages.
It is .

Records are georeference with Latitude, Longitude and average Altitude of centroid
in decimal notation for WGS84.

This file is the base of our datasets, it can be used standalone to build filling forms
and keep user information aligned or as base for the next levels of data as: cities,
postal codes and streets datasets, and a perfect base for our polygons datasets to
display region boundaries on maps.

Mapanet™ / Divex Turismo, S.L. 1 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
POSTAL CODES

All administrative regions, localities, suburbs and postal codes including business and
administrative entities, streets when available, information of time zones and
georeference latitude, longitude (WGS84 datum) and altitude in meters.

This dataset can be easily imported into any software, database, format or GIS
system. The Administrative Regions/Divisions dataset is included as complement.

It is the perfect product if you need to update your contact list, validate forms, build a
store locator, find and display locations on a map, calculate distances between points,
create statistics, and more.

If you need data for certain world regions, we have bulk packages, a great opportunity
to get a complete region at great discounted price.

STREETS

Available for some countries, the Streets datasets are a comprehensive list of street
names, blocks segments enumeration, corporations and city administrative centers
for all mayor cities.
Perfect to build a geocoder, fill forms with standardized address, check and improve
the quality of your addresses or enhance your GIS system. The Administrative
Regions/Divisions dataset is included as complement.

POLYGONS

Available for some countries only, these datasets include a matrix of geographic
coordinates: latitude, longitude in WGS84 datum, and altitude in meters over sea
level to display contours of administrative regions, postal codes, cities and suburbs on
maps such as Google maps, Earth, Bing or any GIS software. Matrix of coordinates can
be used directly in JavaScript or easily converted to practically into any Geo format
such as SHP, Geo JSON, KML, etc., perfect boundaries complement.

Mapanet™ / Divex Turismo, S.L. 2 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
ADDITIONAL RESOURCES

Free data included in the Resources directory containing the complementary tables:

• Continents
• Countries
• Country Names in different languages
• Postal Codes Formats
• ISO 3166-2 codes
• American FIPS codes of countries and administrative regions
• NUTS codes
• Currencies
• Languages
• Tax ID formats
• Time Zones UTC / Olson

Additionally, there are other resources are available at our website:

• Formulas to calculate distance between coordinates with code samples in


several languages as: Java script, ASP, C+, C#, Perl, PHP.

• Formulas to search locations at a given distance from a geographic point


with script samples in ASP and PHP, and a working demo to find Postal
Codes nearby a point.

Mapanet™ / Divex Turismo, S.L. 3 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
FILE FORMATS
Our data are provided in several text and GIS formats which can easily be imported
into any software or database management system. All available formats are stored in
a single zipped file.

Extension Description Separator Delimiter Headers Encoding

.CSV Comma separated values Semicolon {none} Yes UTF-8

.ASC Unformatted ASCII Text Semicolon {none} Yes UTF-8

.SQL MS SQL Server bulk import Semicolon {none} No UTF-16 Big Endian

.JSON Geo Json - - Yes UTF-8

.SHP Shapefile geographic data - - - Binary

Import procedures for most databases and common applications is available in the
DATA IMPORT section of this document where you will find specific details for table
creation and scripts required to perform data import.

Mapanet™ / Divex Turismo, S.L. 4 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
LANGUAGES and CHARACTERS ENCODING
Databases contain by default the names of the localities and regions written in the
local language which may contain accented characters, to preserve accents we use
encoding UTF-8 in the CSV, ASC, JSON files, and Unicode UTF-16 BE for the SQL file.

Non-Latin languages

Languages such as Chinese, Japanese, Russian, etc., an English or Transliterated


version is available in addition to the native language version. Where it is not possible
to make an accurate translation, a transliteration, is provided.

Accents

All datasets have a US-ASCII non-accented 26 letters version with file extension: ASC.

TABLES AND FIELD DESCRIPTIONS


The data is provided in a consistent structure based on data layers, however,
depending on the country, some fields may have null value if country does not use it.

Layer Dataset Description


0 Administrative Regions Country grouping
1 Administrative Regions 1st tier division (state, province or equivalent)
2 Administrative Regions 2nd tier division (municipality, county or equivalent)
3 Administrative Regions 3rd tier division (district, commune or equivalent)
4 Administrative Regions 4th tier division (sub-district or equivalent)
5 Places and Postal Codes Locality
6 Places and Postal Codes Sublocality (township urban village or similar)
7 Places and Postal Codes Neighborhood (suburb, urbanization or equivalent)
8 Streets Street segments (name and exterior number)
9 Streets + Premise Street name, exterior number, and interior identifier

Mapanet™ / Divex Turismo, S.L. 5 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
File names provide information of its content:

Geo-XX-5-STD
↑ ↑ ↑ ↑
| | | STD if single country, PKG if a set of several countries or all world countries
| | |
| | Data layer 4: Adm. regions, 5: City and P.Code, 8: Streets, 9: Street+premise
| |
| Country ISO code, if package of countries:
|
| WE = Western Europe, EE = Eastern Europe, EU = All countries in the European Union
| ME = Middle East, AS = Asia, OC = Oceania
| NA = North America, CC = Central America and the Caribbean, SA = South America
|
GEO for data set with records, POL if data is boundaries polygons sets of coordinates

Mapanet™ / Divex Turismo, S.L. 6 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
Administrative Divisions Geo-XX-4-XXX.csv
Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1

Language varchar(3) Language code ISO 639-1

AdminLevel smallint Administrative level (0 to 4)

CategoryName nvarchar(45) State, Province, County, Municipality ...

CategoryNameEnglish nvarchar(45) State, Province, County, Municipality in English as reference

Region0Code varchar(10) Country group (example: main land, islands)

Region1Code varchar(10) 1st Administrative region code: State

Region2Code varchar(10) 2nd Administrative region code: Municipality

Region3Code varchar(10) 3rd Administrative region code: District

Region4Code varchar(10) 4th Administrative region code: Sub District

RegionName nvarchar(85) Administrative region name

Latitude Decimal(10,7) Decimal - WGS84 datum

Longitude Decimal(10,7) Decimal – WGS84 datum

Altitude Integer Altitude in meters (average)

ISO2 varchar(10) ISO code

FIPS varchar(10) American code

NUTS varchar(30) European Union area code

HASC varchar(12) Statoids

STAT varchar(20) Statstistics organization of country

Mapanet™ / Divex Turismo, S.L. 7 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
Postal Codes Database Geo-XX-5-XXX.csv
Field Data type Description
CountryA2 varchar(3) Country code: ISO 3166-1
Language varchar(3) Language code: ISO 639-1
PostalCode varchar(10) Postal code (ZIP code)
Region0Code varchar(10) Geographic group code
Region0Name nvarchar(85) Geographic group name (main land, island…)
Region1Code varchar(10) Administrative region 1 - code
Region1Name nvarchar(85) Administrative region 1 - name
Region2Code varchar(10) Administrative region 2 - code
Region2Name nvarchar(85) Administrative region 2 - name
Region3Code varchar(10) Administrative region 3 - code
Region3Name nvarchar(85) Administrative region 3 - name
Region4Code varchar(10) Administrative region 4 - code
Region4Name nvarchar(85) Administrative region 4 - name
LocalityCode varchar(12) Locality ID
LocalityType nvarchar(25) Type: City, Town, Village ...
Locality nvarchar(110) Name of City, Town, Village...
SublocalityCode varchar(12) Sub Locality ID
SublocalityType nvarchar(25) Type: Suburb, Township, Colony...
Sublocality nvarchar(110) Name of Suburb, Township, Colony...
AreaCode varchar(10) Area ID
AreaType nvarchar(20) Block, Park, Corporation…
AreaName nvarchar(110) Name of the block, plaza, park, corporation
Latitude Decimal(10, 7) Decimal - WGS84 datum
Longitude Decimal(10, 7) Decimal - WGS84 datum
Altitude integer Altitude in meters over sea level
TimeZone varchar(35) Time Zone name UTC / Olson
UTC Char(6) Local time +/-HH:MM
DST Char(6) Daylight saving time +/- HH:MM

Mapanet™ / Divex Turismo, S.L. 8 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
Streets Geo-XX-8-XXX.csv
Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1
Language varchar(3) Language code ISO 639-1
PostalCode varchar(10) Postal code (ZIP code)
Region0Code varchar(10) Geographic group code (main land, islands)
Region1Code varchar(10) Administrative region 1 - code
Region2Code varchar(10) Administrative region 2 - code
Region3Code varchar(10) Administrative region 3 - code
Region4Code varchar(10) Administrative region 4 - code
LocalityCode varchar(12) Locality ID
LocalityType nvarchar(25) Type: City, Town, Village ...
Locality nvarchar(110) Name of City, Town, Village...
NeighCode varchar(10) Neighborhood ID
NeighType nvarchar(20) Neighborhood type (colonia, urbanization…)
NeighName nvarchar(110) Neighborhood name
StreetCode varchar(12) Street code
StreetType nvarchar(35) Street type (avenue, street, etc)
StreetName nvarchar(110) Street name
StreetNumLow varchar(7) Street segment number: “FROM”, example: 0000A
StreetNumHigh varchar(7) Street segment number: “TO” example: 9999Z
StreetNumOddEven Char(1) Street enumeration (side of street): 0=both, 1=odd, 2=even
StreetBuilding nvarchar(110) Building/Firm name (companies & government buildings)
Latitude Decimal(10, 7) Decimal - WGS84 datum
Longitude Decimal(10, 7) Decimal - WGS84 datum
Altitude integer Altitude in meters over sea level

Mapanet™ / Divex Turismo, S.L. 9 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
RESOURCES DATA
Complementary tables located in the /resources folder of the Zip file you download.
Tables are available only in CSV format, tab separated, with UTF-8 encoding.
(to use them in MS SQL should be to encode it as Unicode UTF-16 Big Endian).

Continents resources/Continents.csv
Field Data type Description
Language varchar(3) Language code ISO 639-1

Code varchar(3) Continent code

Name nvarchar(20) Name in respective language

Countries resources/Countries.csv
hasZipCodes denotes if country have a postal codes system (true, false).
Field LanguagePC contains codes of language datasets available in the Postal Codes
and Streets files separated by comma, ie: EN,PT (English and Portuguese).

Field Data type Description


CountryISO_A2 varchar(2) ISO 3166-1 alpha-2 code

CountryISO_A3 varchar(3) ISO 3166-1 alpha-3 code

NameEnglish nvarchar(45) Country name in English (reference)

LanguageCode varchar(3) Language ISO 639-1 code

LanguagePC varchar(10) Languages of in the dataset, ie: EN,FR

useZipCodes bit Country use Postal Codes? (values: 1=true, 0=false)

PhoneCode varchar(6) Phone prefix

Latitude decimal(7, 3) Decimal notation, WGS84 datum

Longitude decimal(7, 3) Decimal notation, WGS84 datum

TerritoryOf varchar(3) Territory of country: code ISO 3166-1

Updates char(1) Month, Quarter, Annual, Twice/yr. Irregular

Mapanet™ / Divex Turismo, S.L. 10 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
Country Names resources/Country-Names.csv
Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1

Language varchar(3) Language code ISO 639-1

CountryName nvarchar(85) Country name in respective language

Category Nvarchar(20) Category (country or territory in the respective language)

Currencies resources/Currencies.csv
Field Data type Description
Language varchar(3) Language code ISO 639-1

CurrencyISO varchar(3) Currency code ISO 4217

CurrencyName nvarchar(35) Currency name in defined language

Money nvarchar(15) Currency short name in defined language

Symbol Nvarchar(1) Currency symbol

ISO 3166-2 Region codes resources/ISO-3166-2.csv


Field Data type Description
CountryA2 varchar(3) Country code - ISO 3166-1
CountryName nvarchar(50) Country name (as reference, in English)
Category nvarchar(25) Category (province, county, municipality, etc.)
ISO_N3 varchar(2) ISO 3166-1 numeric-3 code
Region nvarchar(85) Region name – in English or Transliterated (Romanized)
Language varchar(2) Language source of region name – language code ISO 639-1
ChangeDate varchar(10) Date of last revision by ISO organization

Mapanet™ / Divex Turismo, S.L. 11 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
FIPS codes Regions resources/FIPS-Admin-Regions.csv
Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1

CountryFIPS varchar(3) Country code FIPS (Pub 10-4)

FIPSContatenated varchar(10) Region concatenated: country + region

Region1FIPS varchar(10) Admin. region code FIPS 1st tier

Region1Name nvarchar(85) Admin. region name 1st tier

Region1Cat nvarchar(20) Admin. region category 1st tier

Region2FIPS varchar(10) Admin. region code FIPS 2nd tier

Region2Name varchar(85) Admin. region name 2nd tier

Region2Cat nvarchar(20) Admin. region category 2nd tier

Latitude decimal(10, 7) Decimal - WGS84 datum

Longitude decimal(10, 7) Decimal - WGS84 datum

Languages resources/Languages.csv
Field Data type Description
Language varchar(3) Language code ISO 3166-1 (for name)

LanguageName nvarchar(80) Language name

ISO_639_1 varchar(2) ISO 639-1 code

ISO_639_2 varchar(3) ISO 639-2 code

Mapanet™ / Divex Turismo, S.L. 12 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
NUTS codes resources/NUTS.csv
Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1

CountryNUTS varchar(3) Country code NUTS

Language varchar(3) Language code ISO 639-1 (for the Name)

NUTS varchar(10) NUTS Region code

Level integer Level: 0-Country, 1st tier, 2nd tier 3rd

Name nvarchar(85) Name of the region / division

Postal Codes Format resources/Postal-Codes-Formats.csv


Useful to control data input in forms in HTML 5 as in example below where browser
will handle the verification automatically.

<input type="text" pattern="Regex" title="Format" placeholder="Format” maxlength="Length" />

Field Data type Description


CountryA2 varchar(3) Country code ISO 3166-1

Denomination nvarchar(30) Name in native language

Format varchar(10) Display format (also to know length)

Regex nvarchar(150) Regex expression example: ^(\d{5})$

Mapanet™ / Divex Turismo, S.L. 13 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
TAX-ID Formats resources/TAX-ID.csv
Useful to validate data in input forms or any other applications. Example below is
shows the usage in HTML 5 so browser verifies format automatically.

<input type="text" pattern="Regex" title="Format" placeholder="Format” maxlength="Length" />

Field Data type Description


CountryA2 varchar(3) Country code ISO 3166-1

CountryName varchar(50) Country name English (reference)

Format varchar(5) Visual format

Length varchar(10) Length of tax ID, min-max (0-99)

Regex varchar(150) Regex expression like: ^(HR)?\d{11}$

AbrevName nvarchar(10) Tax name abbrev: IVA, VAT, etc.

LocalName nvarchar(50) Tax name in native language

Time Zones resources/TimeZones.csv


Field Data type Description
CountryA2 varchar(3) Country code ISO 3166-1

CountryName nvarchar(30) Country name English (as reference)

Olson varchar(50) Time Zone name in Olson nomenclature

UTC char(6) +/-HH:MM Universal Standard Time

DST char(6) +/-HH:MM Daylight Saving Time

ZoneCode varchar(10) Time Zone abbreviation code

ZoneName nvarchar(35) Time Zone name

Mapanet™ / Divex Turismo, S.L. 14 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
DATA IMPORT

In this section you will find procedures to import a dataset to several different
applications and database management. If your application is not included in this
section let us know, we can help you with specific needs.
Note the names in red of database, table or data file are a visual example to guide
you, you must change them according to your system and file:

DATABASE Name of your database.


PostalCodes Name of the table of your choice
Path Path where the file is located, example c:\temp
Geo-XX-0-XXX.csv Name of the file, example: Geo-ES-5-STD.csv

MS Excel
Follow the steps below to import the CSV data in Excel:

• Select all cells and format them as Text so data preserve leading zeroes in codes

• In menu File/Open, select “Text Files (*.prn;*.txt;*.csv)” as type of file

• Browse for file: GEO-XX-5-XXX.csv or Admin. Regions file: Geo-XX-4-XXX.csv

• In import wizard, select Delimited type and 65001: Unicode (URF-8) encoding

• Click Next, select Semicolon (;) as delimiter and {none} as Text qualifier

• Select all columns and define them type: Text to preserve leading zeroes in codes

Please note that the following limits apply to Excel worksheets:

Excel 2003 and Open Spreadsheet: 65 536 rows


Excel 2007 / 2010 / 2013: 1 048 576 rows

Mapanet™ / Divex Turismo, S.L. 15 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS Access
Follow the steps below to import the CSV data in Access:

Note:
Access file limit is 2GB in size, all countries data need 3GB, so can’t be imported.

• Open or create a new Access database

• Open menu File/Get External Data/Import

• Select "Text Files (*.txt;*.csv;*.tab;*.asc)" as type of file

• Browse for file Postal Codes file: GEO-XX-5-XXX.csv or


Admin. Regions file: Geo-XX-4-XXX.csv

• Select Delimited, click on Advanced and select Unicode (UTF‐8) as Code Page

• Click Next, select Semicolon (;) as delimiter and {none} as Text qualifier

• Tick First row contains field names and click on Finish

Mapanet™ / Divex Turismo, S.L. 16 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS SQL - SQL script to create the Administrative Regions table structure
IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'[AdminRegions]') AND type in (N'U'))
DROP TABLE [AdminRegions]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [AdminRegions](


[CountryA2] [varchar](3) NOT NULL,
[Language] [varchar](3) NOT NULL,
[AdminLevel] [int] NOT NULL,
[CategoryName] [nvarchar](45) NOT NULL,
[CategoryNameEnglish] [nvarchar](45) NOT NULL,
[Region0Code] [varchar](10) NOT NULL,
[Region1Code] [varchar](10) NOT NULL,
[Region2Code] [varchar](10) NOT NULL,
[Region3Code] [varchar](10) NOT NULL,
[Region4Code] [varchar](10) NOT NULL,
[RegionName] [nvarchar](85) NOT NULL,
[Latitude] [decimal](10, 7) NULL,
[Longitude] [decimal](10, 7) NULL,
[Altitude] [int] NULL,
[ISO2] [varchar](10)] NULL,
[FIPS] [varchar](10)] NULL,
[NUTS] [varchar](30)] NULL,
[HASC] [varchar](12)] NULL,
[STAT] [varchar](20)] NULL,
CONSTRAINT [PK-AdminRegions] PRIMARY KEY CLUSTERED
(
[CountryA2] ASC,
[Language] ASC,
[Region0Code] ASC,
[Region1Code] ASC,
[Region2Code] ASC,
[Region3Code] ASC,
[Region4Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

Mapanet™ / Divex Turismo, S.L. 17 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS SQL - Script to import the Admin Regions dataset:

BULK INSERT [AdminRegions] FROM 'Path\Geo-XX-4-XXX.sql' WITH


(FIELDTERMINATOR = ';', DATAFILETYPE = 'widechar')

Mapanet™ / Divex Turismo, S.L. 18 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS SQL SERVER SQL script to create the Postal Codes table structure:

IF EXISTS (SELECT * FROM sys.objects


WHERE object_id = OBJECT_ID(N'[PostalCodes]') AND type in (N'U')) DROP TABLE
[PostalCodes]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [PostalCodes](


[ID] [bigint] IDENTITY(1,1) NOT NULL,
[CountryA2] [varchar](3) NOT NULL,
[Language] [varchar](3) NOT NULL,
[PostalCode] [varchar](10) NOT NULL,
[Region0Code] [varchar](10) NULL,
[Region0Name] [nvarchar](85) NULL,
[Region1Code] [varchar](10) NOT NULL,
[Region1Name] [nvarchar](85) NOT NULL,
[Region2Code] [varchar](10) NULL,
[Region2Name] [nvarchar](85) NULL,
[Region3Code] [varchar](10) NULL,
[Region3Name] [nvarchar](85) NULL,
[Region4Code] [varchar](10) NULL,
[Region4Name] [nvarchar](85) NULL,
[LocalityCode] [varchar](12) NULL,
[LocalityType] [nvarchar](25) NULL,
[Locality] [nvarchar](110) NOT NULL,
[SubLocalityCode] [varchar](12) NULL,
[SubLocalityType] [nvarchar](25) NULL,
[SubLocality] [nvarchar](110) NULL,
[AreaCode] [varchar](10) NULL,
[AreaType] [nvarchar](20) NULL,
[AreaName] [nvarchar](110) NULL,
[Latitude] [decimal](10,7) NULL,
[Longitude] [decimal](10,7) NULL,
[Altitude] [int] NULL,
[TimeZone] [varchar](35) NULL,
[UTC] [char](6) NULL,
[DST] [char](6) NULL,
CONSTRAINT [PK_PostalCodes] PRIMARY KEY CLUSTERED
(
[CountryA2] ASC,
[Language] ASC,
[Region1Code] ASC,
[Locality] ASC,
[PostalCode] ASC,
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

Mapanet™ / Divex Turismo, S.L. 19 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS SQL SERVER - Script to import the dataset:

BULK INSERT [PostalCodes] FROM 'c:\path\Geo-XX-5-XXX.sql' WITH


(FIELDTERMINATOR = ';', DATAFILETYPE = 'widechar')

Mapanet™ / Divex Turismo, S.L. 20 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
MS SQL SQL – Sample SQL script to create the Streets table:
IF EXISTS (SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'[Streets]') AND type in (N'U')) DROP TABLE
[Streets]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [Streets](


[ID] [bigint] IDENTITY(1,1) NOT NULL,
[CountryA2] [varchar](3) NOT NULL,
[Language] [varchar](3) NOT NULL,
[PostalCode] [varchar](10) NOT NULL,
[Region0Code] [varchar](10) NULL,
[Region1Code] [varchar](10) NOT NULL,
[Region2Code] [varchar](10) NULL,
[Region3Code] [varchar](10) NULL,
[Region4Code] [varchar](10) NULL,
[LocalityCode] [varchar](12) NULL,
[LocalityType] [nvarchar](25) NULL,
[Locality] [nvarchar](110) NOT NULL,
[NeighCode] [varchar](10) NULL,
[NeighType] [nvarchar](20) NULL,
[NeighName] [nvarchar](110) NULL,
[StreetCode] [varchar](10) NULL,
[StreetType] [nvarchar](35) NULL,
[StreetName] [nvarchar](110) NULL,
[StreetNumLow] [varchar](7) NULL,
[StreetNumHigh] [varchar](7) NULL,
[StreetNumOddEven] [char](1) NULL,
[StreetBuilding] [nvarchar](110) NULL,
[Latitude] [decimal](10,7) NULL,
[Longitude] [decimal](10,7) NULL,
[Altitude] [int] NULL,
CONSTRAINT [PK_Streets] PRIMARY KEY CLUSTERED
(
[CountryA2] ASC,
[Language] ASC,
[Region1Code] ASC,
[Locality] ASC,
[PostalCode] ASC,
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

Bulk import command:


BULK INSERT [Streets] FROM 'c:\path\Geo-XX-8-XXX.sql' WITH
(FIELDTERMINATOR = ';', DATAFILETYPE = 'widechar')

Mapanet™ / Divex Turismo, S.L. 21 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
mySQL

SQL script to create the Administrative Regions table structure and indexes:

DROP TABLE IF EXISTS AdminRegions;

CREATE TABLE AdminRegions (


CountryA2 varchar(3) NOT NULL,
Language varchar(3) NOT NULL,
AdminLevel integer NOT NULL,
CategoryName varchar(45) NOT NULL,
CategoryNameEnglish varchar(45) NOT NULL,
Region0Code varchar(10) NOT NULL,
Region1Code varchar(10) NOT NULL,
Region2Code varchar(10) NOT NULL,
Region3Code varchar(10) NOT NULL,
Region4Code varchar(10) NOT NULL,
RegionName varchar(85) NOT NULL,
Latitude decimal(10, 7),
Longitude decimal(10, 7),
Altitude integer,
ISO2 varchar(10) NULL,
FIPS varchar(10) NULL,
NUTS varchar(30) NULL,
HASC varchar(12) NULL,
STAT varchar(20) NULL,
PRIMARY KEY (CountryA2, Language, Region0Code, Region1Code,
Region2Code, Region3Code, Region4Code)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8mb4_0900_ai_ci;

SQL script to import the CSV dataset:

LOAD DATA INFILE '/path/Geo-XX-4-XXX.csv'


INTO TABLE AdminRegions
FIELDS TERMINATED BY ';' ESCAPED BY '\\' IGNORE 1 LINES;

Mapanet™ / Divex Turismo, S.L. 22 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
mySQL

SQL script to create the Postal Codes table structure and indexes:

DROP TABLE IF EXISTS PostalCodes;

CREATE TABLE PostalCodes (


ID bigint(20) AUTO_INCREMENT NOT NULL,
CountryA2 varchar(3) NOT NULL,
Language varchar(3) NOT NULL,
PostalCode varchar(10),
Region0Code varchar(10),
Region0Name varchar(85),
Region1Code varchar(10) NOT NULL,
Region1Name varchar(85) NOT NULL,
Region2Code varchar(10),
Region2Name varchar(85),
Region3Code varchar(10),
Region3Name varchar(85),
Region4Code varchar(10),
Region4Name varchar(85),
LocalityCode varchar(12),
LocalityType varchar(25),
Locality varchar(110) NOT NULL,
SubLocalityCode varchar(12),
SubLocalityType varchar(25),
SubLocality varchar(110),
AreaCode varchar(10),
AreaType varchar(20),
AreaName varchar(110),
Latitude decimal(10, 7),
Longitude decimal(10, 7),
Altitude integer,
TimeZone varchar(35),
UTC varchar(6),
DST varchar(6),
PRIMARY KEY
(`CountryA2`,`Language`,`PostalCode`,`Region1Code`,`Locality`,`ID`),
UNIQUE KEY `ID_UNIQUE` (`ID`),
KEY `PK`
(`CountryA2`,`Language`,`Region1Code`,`Locality`,`PostalCode`,`ID`),
KEY `PK_PC` (`CountryA2`,`Language`,`PostalCode`,`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Mapanet™ / Divex Turismo, S.L. 23 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
Script to import the CSV dataset:

LOAD DATA INFILE '/path/Geo-XX-5-XXX.csv'


INTO TABLE PostalCodes
FIELDS TERMINATED BY ';' ESCAPED BY '\\' IGNORE 1 LINES
(CountryA2, Language, PostalCode, Region0Code, Region0Name,
Region1Code, Region1Name, Region2Code, Region2Name, Region3Code,
Region3Name, Region4Code, Region4Name, LocalityCode, LocalityType,
Locality, SubLocalityCode, SubLocalityType, SubLocality, AreaCode,
AreaType, AreaName, Latitude, Longitude, Altitude, TimeZone, UTC,
DST);

Mapanet™ / Divex Turismo, S.L. 24 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
ORACLE

SQL script to create the Administrative Regions table structure and indexes:

DROP TABLE IF EXISTS AdminRegions;

CREATE TABLE AdminRegions (


CountryA2 varchar(3) NOT NULL,
Language varchar(3) NOT NULL,
AdminLevel integer NOT NULL,
CategoryName varchar(45) NOT NULL,
CategoryNameEnglish varchar(45) NOT NULL,
Region0Code varchar(10) NOT NULL,
Region1Code varchar(10) NOT NULL,
Region2Code varchar(10) NOT NULL,
Region3Code varchar(10) NOT NULL,
Region4Code varchar(10) NOT NULL,
RegionName varchar(85) NOT NULL,
Latitude number(10, 7,
Longitude number(10, 7),
Altitude integer,
ISO2 varchar(10) NULL,
FIPS varchar(10) NULL,
NUTS varchar(30) NULL,
HASC varchar(12) NULL,
STAT varchar(20) NULL,
CONSTRAINT AdminRegions_PK PRIMARY KEY (Country, Language,
Region0Code, Region1Code, Region2Code, Region3Code, Region4Code)
)

SQL script to import from the CSV dataset:

ORGANIZATION EXTERNAL
( DEFAULT DIRECTORY xtern_data_dir
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ';'
)
LOCATION ('/path/Geo-XX-4-XXX.csv')
);

Mapanet™ / Divex Turismo, S.L. 25 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España
ORACLE
SQL script to create the Postal Codes table structure and indexes:

DROP TABLE IF EXISTS PostalCodes;

CREATE TABLE PostalCodes (


ID number GENERATED BY DEFAULT AS IDENTITY,
CountryA2 varchar(3) NOT NULL,
Language varchar(3) NOT NULL,
PostalCode varchar(10) NOT NULL,
Region0Code varchar(10),
Region0Name varchar(85),
Region1Code varchar(10) NOT NULL,
Region1Name varchar(85) NOT NULL,
Region2Code varchar(10),
Region2Name varchar(85),
Region3Code varchar(10),
Region3Name varchar(85),
Region4Code varchar(10),
Region4Name varchar(85),
LocalityCode varchar(12),
LocalityType varchar(25),
Locality varchar(110) NOT NULL,
SubLocalityCode varchar(12),
SubLocalityType varchar(25),
SubLocality varchar(110),
AreaCode varchar(10),
AreaType varchar(20),
AreaName varchar(110),
Latitude number(10, 7),
Longitude number(10, 7),
Altitude integer,
TimeZone varchar(35),
UTC varchar(6),
DST varchar(6),
CONSTRAINT PostalCodes_PK PRIMARY KEY (CountryA2, Language,
PostalCode, Region1Code, Locality, ID) )

Importing the data from CSV file:

ORGANIZATION EXTERNAL ( DEFAULT DIRECTORY xtern_data_dir


ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ';')
LOCATION ('/path/Geo-XX-5-XXX.csv'));

Mapanet™ / Divex Turismo, S.L. 26 Calle Zurbano No. 45, 1º


www.mapanet.eu Madrid 28010 España

You might also like