Shape file into GMT

Dear all,

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.

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 

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

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

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 
./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$ 

trying with a diferent shape file

./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)

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.

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

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

1 Like

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

Fallas_Cuaternarias.zip (774.2 KB)

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…

In the link I explained how to convert shp to txt for GMT. In your txt file, each line (or polygon) should be separated with >.

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

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

1 Like

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.

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)

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)

1 Like

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!

1 Like

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

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

any particular reason why shows up this ERROR

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

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

] add GMT

and then before using it

using GMT
1 Like