Working with polys


Could you please provide more details on working with polys. There are a lot of examples on working with custom polygon shapes. But the documentation ( is quite lenient.
Is there any description of requirements to the polys database table? Is there any sample data I can look at? Any recommended approach to converting of arcGIS to polys?



Sure. I’ll provide a primer on working with polys currently.

I’ll preface this by saying that our current polygon support is for backend polygon rendering only. We currently do not support any geospatial querying against polygon tables (such as postgis’ ST_Contains, ST_Distance, etc.). Tho, you can run SQL queries against polygon tables, including joins, to produce choropleths and the like.

We are currently working on formal geospatial query support which should be released sometime early next year which may impact some of the following details.


You can import KML, GEOJSON, or SHAPEFILES. If you want to import data from arcGIS you’ll need to export your data into one of these formats.

Importing poly data can be done through two interfaces, either via immerse:

or via mapql (our command-line interface) using the \copygeo command:

Note that when importing shapefiles (.shp), a .shx and .dbf files are also required and need to be in the same directory as the .shp. You only need to supply the .shp file via the import commands tho.


  1. We only support importing polygon and multipolygon types currently. Trying to import anything else; Point, Multipoint, LineString, etc. will result in an error.

  2. Vertex data must be in WGS84 lat/lon coordinates.

  3. We currently do not support holes. Polygons with holes can be properly imported, but renders will lack holes.

  4. We currently only support simple polygons. Trying to import complex polygons (i.e. polygons with self-intersections) will result in an error. If exporting from arcGIS, be sure to remove any self-intersections first (I believe arcGIS has tools for this).

At import, 4 columns will be added internally for rendering (mapd_geo_coords, mapd_geo_indices, mapd_geo_linedrawinfo, mapd_geo_polydrawinfo). Note these are added for rendering purposes only and should not generally be queried against. The mapd_geo_coods contains the vertex data converted from WGS84 to mercator.

Any other columns described in the imported poly file will also be added which can be used to join against.


At present, Immerse does not have support for backend-rendered polygons. The only way to render polygons currently is to run a render_vega request against the server. See:

for some info on what a vega that renders polys should look like.


  1. biggest caveat is table size. If you try to import a very large polygon file, you’re likely to run into performance problems. So try to work within modest polygon sizes (i.e. try not to import polygon files with millions of polygons)

Lastly, if you want to play with some data, here’s a good example polygon shapefile of the US zipcodes you can play with:

This shapefile is of reasonable size and imports fine (approx 35K polygons)

Hopefully that’s enough to get you started. If you begin to start playing with this and have more questions, let us know.

NOTE that all above caveats should be addressed when our geo support rolls out so stay tuned for that.




Some earlier discussions here as well MapD Import and Render GeoJSON Shapes



Thanks a lot. This is really helpful.


Tried to play with zipcodes shapes.
I imported it into core with \copygeo command. Could You please suggest how to verify it? I don’t see any new tables with \t in mapdql.


in mapql should tell you the tables (and it’d probably be the last one printed in the list), so if it’s not there, check the mapd_server.INFO log to see if it has any meaningful output that may assist.
You can also run \d <table name> from mapdql to get specific import info on a table rather than trying to parse through the \t output.
If \d <table name results in Table <table name> doesn't exist, then something surely didn’t work.


\t shows nothing. Any ideas?

I1202 09:02:41.945648 29694 MapDHandler.cpp:2488] import_geo_table zipcodes from /home/alexgg/zipcodes_geo.geojson
I1202 09:02:43.947022 29694 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 09:02:43.947499 29694 MapDHandler.cpp:2488] import_geo_table zipcodes from /home/alexgg/zipcodes_geo.geojson
I1202 09:02:47.948427 29694 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 09:02:47.948876 29694 MapDHandler.cpp:2488] import_geo_table zipcodes from /home/alexgg/zipcodes_geo.geojson
I1202 09:02:55.950178 29694 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 09:02:55.950692 29694 MapDHandler.cpp:2488] import_geo_table zipcodes from /home/alexgg/zipcodes_geo.geojson


i tried with a geojson file i am using on mapd

\copygeo /opt/mapd/mapd-ce-3.3.0-20171026-ed76a7a-Linux-x86_64-render/frontend/geojson/italy_regions_lowres.json italy_regions

\d italy_regions
CREATE TABLE italy_regions (
mapd_geo_coords DOUBLE[],
mapd_geo_indices INTEGER[],
mapd_geo_linedrawinfo INTEGER[],
mapd_geo_polydrawinfo INTEGER[])

in the log-info
I1202 07:23:14.168218 19564 MapDHandler.cpp:2419] import_geo_table italy_regions from /opt/mapd/mapd-ce-3.3.0-20171026-ed76a7a-Linux-x86_64-render/frontend/geojson/italy_regions_lowres.json
I1202 07:23:14.171933 19564 MapDHandler.cpp:568] sql_execute :LU4P3Rr4Tl8ofEvRx2nP9DbFqCsquUu0:query_str:CREATE TABLE italy_regions (COD_REG INTEGER , NOME_REG TEXT ENCODING DICT , SHAPE_Leng DOUBLE , SHAPE_Area DOUBLE , mapd_geo_coords DOUBLE[] , mapd_geo_indices INTEGER[] , mapd_geo_linedrawinfo INTEGER[] , mapd_geo_polydrawinfo INTEGER[] );
I1202 07:23:14.171952 19564 MapDHandler.cpp:3187] passing query to legacy processor
I1202 07:23:14.183626 19564 Calcite.cpp:179] Time to updateMetadata 0 (ms)
I1202 07:23:14.183722 19564 MapDHandler.cpp:586] sql_execute-COMPLETED Total: 11 (ms), Execution: 5 (ms)
I1202 07:23:14.183815 19564 Catalog.cpp:1520] Instantiating Fragmenter for table italy_regions took 0ms
I1202 07:23:14.191521 19564 Catalog.cpp:1566] Time to load Dictionary 529 was 7ms
I1202 07:23:23.580411 19564 FileMgr.cpp:173] Completed Reading table’s file metadata, Elasped time : 91ms Epoch: 30 files read: 4 table location: ‘/opt/mapd_storage/data/mapd_data/table_1_1/’

the command doent give any feedback to the user, but it’s a very old command introduced as experimental


I am running it on mapd 3.3.1. Do You think it worth to downgrade to 3.3.0?
Is there any way to get more detailed logs?


i will upgrade to 3.3.1 and retry…i forgot to upgrade and i have to try what i am developing with actual release

in meanwhile here is the file i loaded witth copygeo command; you can try to import on your system (4.6 KB)


i tried with mapd 3.3.1 and the copygeo command worked as in 3.3.0 so i guess the problem is relying on the file you have imported; if you will share i will try on my system


The same results with Your file. The command finished silently, \t shows nothing, following in log:

I1202 10:06:16.191591 32464 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 10:06:30.666097 32464 MapDHandler.cpp:2488] import_geo_table italy from /home/alexgg/Downloads/italy_regions_lowers.json
I1202 10:06:32.667578 32464 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 10:06:32.668005 32464 MapDHandler.cpp:2488] import_geo_table italy from /home/alexgg/Downloads/italy_regions_lowers.json
I1202 10:06:36.668954 32464 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 10:06:36.671049 32464 MapDHandler.cpp:2488] import_geo_table italy from /home/alexgg/Downloads/italy_regions_lowers.json
I1202 10:06:44.671953 32464 MapDHandler.cpp:349] User mapd connected to database mapd
I1202 10:06:44.672401 32464 MapDHandler.cpp:2488] import_geo_table italy from /home/alexgg/Downloads/italy_regions_lowers.json


it seems an eviroment problems; have you gdal installed on your system?


No. Never saw it in installation manual
Should I install it?


in fact it was installed:
gdal-bin is already the newest version (1.11.3+dfsg-3build2)


i am looking at the code an di really can’t see how is possible you are not getting feedback (well i am not a developer of mapd-core anyway)

could you try to remove read permission on the files you are trying to load?


Thank You!
Changing of permissions solved everything!


I cannot believe with the wrong permission you would get some exception.

Anyway devils is in the detail as always


@alexei-grigoriev we just released MapD 4.0 and it has support for many more geospatial data types and functions.