# Shape file into GMT

**URL:** <https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685>\
**Category:** Q&A\
**Created:** [July 18, 2020, 7:03pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685 "2020-07-18T19:03:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:03pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/1 "2020-07-18T19:03:15Z")

</div>

Dear all,

 ![audemardf_fallas](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/4a294bad307eb5004369701b3431a4622e80283b.png)

I was wondering if you could help, I have several shape files that I would like to have in my GMT maps. Is it possible to have them read an ploted ? I have try exporting them as xy.txt files and plot them with psxy and plot commands but I am getting not a nice image.

```auto
gmt begin audemardf_fallas pdf,png 

gmt coast -JM30c -R-75/-55/0/15 -Wfaint,blue -Gwhite -Sazure -Baf -N1/thick,black 
gmt psxy audemardf_fallas_c1.txt -JM30c -R-75/-55/0/15 -Baf -Wfaint,red,dash

gmt end show 

```

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [July 18, 2020, 7:14pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/2 "2020-07-18T19:14:52Z")

</div>

Have you tried giving _plot_ the name of the shape file (\*.shp)?

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:32pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/3 "2020-07-18T19:32:07Z")

</div>

I have just tried, is not plotting the Faults on the map  
below the modification on the script and the result in the terminal

```auto
gmt begin audemardf_fallas pdf,png 

gmt coast -JM30c -R-75/-55/0/15 -Wfaint,blue -Gwhite -Sazure -Baf -N1/thick,black 
gmt plot Fallas_Cuaternarias_Venezuela_lineas.shp -JM30c -R-75/-55/0/15 -Baf -Wfaint,red,dash

gmt end show 

```

```auto
./audemardf_fallas.sh: line 1: !#usr/bin/env: No such file or directory
ERROR 4: Unable to open Fallas_Cuaternarias_Venezuela_lineas.shx or Fallas_Cuaternarias_Venezuela_lineas.SHX. Set SHAPE_RESTORE_SHX config option to YES to restore or create it.
FAILURE:
Unable to open datasource `Fallas_Cuaternarias_Venezuela_lineas.shp' with the following drivers.
  -> `PCIDSK'
  -> `netCDF'
  -> `PDS4'
  -> `JP2OpenJPEG'
  -> `PDF'
  -> `MBTiles'
  -> `EEDA'
  -> `ESRI Shapefile'
  -> `MapInfo File'
  -> `UK .NTF'
  -> `OGR_SDTS'
  -> `S57'
  -> `DGN'
  -> `OGR_VRT'
  -> `REC'
  -> `Memory'
  -> `BNA'
  -> `CSV'
  -> `GML'
  -> `GPX'
  -> `KML'
  -> `GeoJSON'
  -> `GeoJSONSeq'
  -> `ESRIJSON'
  -> `TopoJSON'
  -> `OGR_GMT'
  -> `GPKG'
  -> `SQLite'
  -> `WAsP'
  -> `OpenFileGDB'
  -> `XPlane'
  -> `DXF'
  -> `CAD'
  -> `Geoconcept'
  -> `GeoRSS'
  -> `GPSTrackMaker'
  -> `VFK'
  -> `PGDUMP'
  -> `OSM'
  -> `GPSBabel'
  -> `SUA'
  -> `OpenAir'
  -> `OGR_PDS'
  -> `WFS'
  -> `WFS3'
  -> `HTF'
  -> `AeronavFAA'
  -> `EDIGEO'
  -> `GFT'
  -> `SVG'
  -> `CouchDB'
  -> `Cloudant'
  -> `Idrisi'
  -> `ARCGEN'
  -> `SEGUKOOA'
  -> `SEGY'
  -> `ODS'
  -> `XLSX'
  -> `ElasticSearch'
  -> `Carto'
  -> `AmigoCloud'
  -> `SXF'
  -> `Selafin'
  -> `JML'
  -> `PLSCENES'
  -> `CSW'
  -> `VDV'
  -> `MVT'
  -> `TIGER'
  -> `AVCBin'
  -> `AVCE00'
  -> `NGW'
  -> `HTTP'
plot [ERROR]: System call [ogr2ogr -mapFieldType Integer64=Integer -f "OGR_GMT" /var/folders/q4/f3vkf3lj7cg8fx8tp866cmt00000gn/T/gmt_ogr_3248.gmt Fallas_Cuaternarias_Venezuela_lineas.shp] FAILED with error 256.
plot [ERROR]: Cannot open file Fallas_Cuaternarias_Venezuela_lineas.shp
bash-3.2$ 

```

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:45pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/4 "2020-07-18T19:45:43Z")

</div>

trying with a diferent shape file

````auto
./audemardf_fallas.sh: line 1: !#usr/bin/env: No such file or directory
ERROR 1: Features without geometry not supported by GMT writer.
ERROR 1: Unable to write feature 434 from layer Fallas_Cuaternarias_Triangulo_2.
ERROR 1: Terminating translation prematurely after failed
translation of layer Fallas_Cuaternarias_Triangulo_2 (use -skipfailures to skip errors)
plot [ERROR]: System call [ogr2ogr -mapFieldType Integer64=Integer -f "OGR_GMT" /var/folders/q4/f3vkf3lj7cg8fx8tp866cmt00000gn/T/gmt_ogr_3440.gmt Fallas_Cuaternarias_Triangulo_2.shp] FAILED with error 256.
plot [ERROR]: Cannot open file Fallas_Cuaternarias_Triangulo_2.shp
bash-3.2$ 
bash-3.2$ ```

![Screenshot 2020-07-18 15.44.58|690x421](upload://cPlUkcT6cKA3fj8sN4Kc4QqUv9l.png)
````

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 18, 2020, 7:46pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/5 "2020-07-18T19:46:38Z")

</div>

The `.shx` is the index file and should not be mandatory to read the shape file. If you can make that shapefile available we can look (see if my gdal is more permissive?). But only within two couple of hours.

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:48pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/6 "2020-07-18T19:48:03Z")

</div>

Okey, please may I have an e-mail to send the folder

 ![Screenshot 2020-07-18 15.44.58](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/59e82a86ae410d88f7abc5dcb1a05de37e1a9a1f.png)

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [July 18, 2020, 7:48pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/7 "2020-07-18T19:48:14Z")

</div>

Also fix your shebang line (1st line in the script). Should be #!/usr/bin/env bash

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 18, 2020, 7:49pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/8 "2020-07-18T19:49:30Z")

</div>

If file is not too big you can zip it and post it here (drag-n-drop). Otherwise post a link.

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:53pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/9 "2020-07-18T19:53:46Z")

</div>

[Fallas\_Cuaternarias.zip](https://forum.generic-mapping-tools.org/uploads/short-url/o07tx9ibjmb9Ce5Z5Y41NSvSdjg.zip) (774.2 KB)

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 7:57pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/10 "2020-07-18T19:57:56Z")

</div>

these are the shapefiles I am trying to get into GMT, still, geological units are missing but I can begin with faults

Uploading: Fallas\_Cuaternarias.zip…

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [July 18, 2020, 9:13pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/11 "2020-07-18T21:13:50Z")

</div>

In the [link](http://mapasgeologicos.blogspot.com/2016/01/anexo-1-convertir-datos-vectoriales-shp.html?m=1) I explained how to convert shp to txt for GMT. In your txt file, each line (or polygon) should be separated with \>.

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 18, 2020, 10:47pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/12 "2020-07-18T22:47:41Z")

</div>

My QGIS version don’t have GMT format to export which QGIS is this version is it MacOsX?  
I try usin ESRI Shapefile format , and the plot command… and is not working

 ![Screenshot 2020-07-18 18.25.23](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/16b6b7b8c2d5aeeb65b0f75e0ce7daee8b61c924.png)

---

<div class="post-metadata">

**Author:** ![gery](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@gery](https://forum.generic-mapping-tools.org/u/gery)\
**Post date:** [July 19, 2020, 12:50am UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/13 "2020-07-19T00:50:19Z")

</div>

Hola K.,

This works:

> for shp in \*.shp  
> do  
> nombre=`basename $shp .shp`  
> ogr2ogr -f “GMT” ${nombre}.gmt $shp -skipfailures  
> done

It generates these ones but just ignore them:

> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> ERROR 1: Features without geometry not supported by GMT writer.  
> Warning 1: The output driver does not seem to natively support Integer64 type for field ID. Converting it to Real instead. -mapFieldType can be used to control field type conversion.  
> Warning 1: The output driver does not seem to natively support Integer64 type for field ID. Converting it to Real instead. -mapFieldType can be used to control field type conversion.  
> ERROR 1: Features without geometry not supported by GMT writer.

Check the enclosed image, plotted with GMT (6!!!) and QGIS.

Hope this helps,

Gery

 ![Captura de pantalla de 2020-07-18 19-48-40](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/cf3af71ac57953275d1e361cd2e64d932ac4280d.png)

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 19, 2020, 1:09am UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/14 "2020-07-19T01:09:42Z")

</div>

Muchas gracias! lo voy a intentar!, la imagen en GMT tiene algunos detalles sigue conectando algunos polígonos que no se encuentran conectados entre ellos realmente.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 19, 2020, 1:36am UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/16 "2020-07-19T01:36:57Z")

</div>

Not sure why _fancy_ is off, but another (so simpler) alternative. With GMT Julia (and mixed mode, sorry the other I don’t remember from hart)

```auto
D = gmtread("c:/v/Fallas_Cuaternarias/Fallas_Cuaternarias_Venezuela_lineas.shp");
coast(region=(-75,-55,0,15), proj=:Mercator, figsize=17, W="faint,blue", G="white", S="azure", N="1/thick,black")
plot!(D, W="faint,red,dash", fmt=:png, show=true)

```

 ![GMTjl_tmp](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/f765717cb20e0eb0fdb2d0a84682940611f595ea.png)

---

<div class="post-metadata">

**Author:** ![gery](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@gery](https://forum.generic-mapping-tools.org/u/gery)\
**Post date:** [July 19, 2020, 1:37am UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/17 "2020-07-19T01:37:39Z")

</div>

Sip, tienes razón, well, some features are not connected because it’s a quick plot, start playing with that piece of code to get the gmt files first, once you have them you need to plot them separately. Please keep us updated about your progress.

Gusto ayudarte!

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 19, 2020, 2:01am UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/18 "2020-07-19T02:01:00Z")

</div>

I will try this way as well it looks so Beautiful! this is exacly how it should look like

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 19, 2020, 5:57pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/19 "2020-07-19T17:57:52Z")

</div>

Dear Joaquim I am at the moment installing GMT Julia , which I am consulting the installation process from this page [http://gmt.soest.hawaii.edu/doc/latest/julia\_wrapper.html#installing](http://gmt.soest.hawaii.edu/doc/latest/julia_wrapper.html#installing)

any particular reason why shows up this ERROR

 ![Screenshot 2020-07-19 13.54.26](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/08cfae38f4291e2d8728669e042741066369415c.png)

Hope not to take too much of your time and thank you

---

<div class="post-metadata">

**Author:** ![KRL](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/krl/32/583_2.png) [@KRL](https://forum.generic-mapping-tools.org/u/KRL)\
**Post date:** [July 19, 2020, 6:10pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/20 "2020-07-19T18:10:14Z")

</div>

![Screenshot 2020-07-19 14.09.37](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/605f3439406100c1c2c1e01689882d0f7e4b8cd8.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 19, 2020, 8:05pm UTC](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685/21 "2020-07-19T20:05:22Z")

</div>

In Julia, like in Python, before using a package you must load it first. But just do like is explain in the readme page, Type

```auto
] add GMT

```

and then before using it

```auto
using GMT

```

[Next page](https://forum.generic-mapping-tools.org/t/shape-file-into-gmt/685.md?page=2)
