# Plotting and labeling shapefiles with -a (aspatial data)

**URL:** <https://forum.generic-mapping-tools.org/t/plotting-and-labeling-shapefiles-with-a-aspatial-data/5710>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [January 31, 2025, 12:35am UTC](https://forum.generic-mapping-tools.org/t/plotting-and-labeling-shapefiles-with-a-aspatial-data/5710 "2025-01-31T00:35:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielheaton](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/danielheaton/32/4705_2.png) [@danielheaton](https://forum.generic-mapping-tools.org/u/danielheaton)\
**Post date:** [January 31, 2025, 12:35am UTC](https://forum.generic-mapping-tools.org/t/plotting-and-labeling-shapefiles-with-a-aspatial-data/5710/1 "2025-01-31T00:35:02Z")

</div>

I have a shapefile that outlines magnetic lineations that I created in QGIS. The shapefile has attributes that label the individual vectors/lines with the chron.

I want to plot the shapefile, and then label the chron lines with the respective chron assignment. I only want the magnetic lineations labeled once.

“chron” is the name of the attribute.

```auto
    # Plot the shapefile
    gmt plot $SHAPEFILE.shp -W1p,blue -aT=chron

```

I calculate the midpoints of the vectors, and export them to a text file. I can’t seem to export the “chron” attribute along with the vector midpoint. It just exports the lon/lat.

```auto
   # Calculate the midpoints of the vectors and extract the attribute
  gmt spatial $SHAPEFILE.shp -Qk -fg -aL=chron | gmt convert -i0,1 > midpoints.txt

```

Is there a way to label my segments from a shapefile using attributes?

Thanks!

---

<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:** [February 1, 2025, 5:26pm UTC](https://forum.generic-mapping-tools.org/t/plotting-and-labeling-shapefiles-with-a-aspatial-data/5710/2 "2025-02-01T17:26:13Z")

</div>

> [@danielheaton](#):
>
> `gmt convert -i0,1`

I’m not very fan of **-a** and shapes in GMT CLI, so I know little about it but that **-i0,1** clearly drops anything else than the x,y coordinates.
