# Issue with add a new property to a feature in pygplates

**URL:** <https://discourse.gplates.org/t/issue-with-add-a-new-property-to-a-feature-in-pygplates/156>\
**Category:** Q&A\
**Created:** [4 August 2020 20:28 UTC](https://discourse.gplates.org/t/issue-with-add-a-new-property-to-a-feature-in-pygplates/156 "2020-08-04T20:28:24Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![john.cannon](https://discourse.gplates.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@john.cannon](https://discourse.gplates.org/u/john.cannon)\
**Post date:** [24 September 2020 14:01 UTC](https://discourse.gplates.org/t/issue-with-add-a-new-property-to-a-feature-in-pygplates/156/12 "2020-09-24T14:01:25Z")

</div>

Hi Thomas,

Oh I see what the problem is (thanks for posting your code by the way). Actually this is the first time I’ve noticed this problem. The problem has to do with writing out to GPML and then reading back in again (that is, properties not defined in the GPlates information model). On reading back in, they are _not_ interpreted/parsed because it’s not a property that’s recognised/defined by the GPlates information model (so it doesn’t really know how to read/create it). This is different than directly adding a property to a feature using pyGPlates (with `pygplates.VerifyInformationModel.no`) such as:

```
feature.add(
    pygplates.PropertyName.create_gpml('isochron_age'),
    pygplates.XsDouble(begin_time),
    pygplates.VerifyInformationModel.no)

```

…because there you know the type (`XsDouble`) of the property (ie, you obviously know `begin_time` is a float and not something else like a string). However when the same property is read from a GPML file, the only information pyGPlates has is:

```
<gpml:isochron_age>100</gpml:isochron_age>

```

…which says nothing about the _type_ (ie, `100` could be a string or a number). If this property had been in the information model then GPlates would know that `gpml:isochron_age` was a number (and be able to load it into an XsDouble or XsInteger rather than an XsString or something else). There are ways to define the _type_ in XML but, for simple non-structural types in GPlates, this is how we currently do it.

This is basically an issue we are starting to deal with, which is loosening up restrictions of the GPlates information model to better allow arbitrary user-defined properties (and also easier/better mapping between attributes in other formats, like Shapefiles, and the GPlates information model).

In the meantime, a workaround is to co-opt one of the [existing properties](https://www.gplates.org/docs/gpgim/#PropertyList) in the GPlates information model. Or, even better, use the Shapefile attributes (which is actually [one of those properties](https://www.gplates.org/docs/gpgim/#gpml:shapefileAttributes) whose value is a dictionary of attributes). These attributes will survive writing out to GPML and reading back in again (because their contents are rather simple, and they are not dictated by the GPlates information model):

```
output_feature.set_shapefile_attribute('isochron_age', begin_time)

# Write feature out to GPML and read back in again.
pygplates.FeatureCollection(output_feature).write('tmp.gpml')
input_feature = list(pygplates.FeatureCollection('tmp.gpml'))[0]

begin_time = input_feature.get_shapefile_attribute('isochron_age')

```

You can write as many Shapefile attributes as you want. Each attribute can be either a [string, integer or float](https://www.gplates.org/docs/pygplates/generated/pygplates.Feature.html#pygplates.Feature.set_shapefile_attribute) (in your case `begin_time` is a float). I guess just be careful not to clobber any existing Shapefile attribute (eg, if your feature originally came from a Shapefile that had some of its own attributes that you want to keep around).

Regards,  
John

---

_[View the full topic](https://discourse.gplates.org/t/issue-with-add-a-new-property-to-a-feature-in-pygplates/156)._
