Question

Translate from shp to gpkg

  • 28 February 2023
  • 4 replies
  • 17 views

Badge +1

I want to translate a dataset from shp to gpkg

There is a id field in attribute table in shp file.

I added the transformer "attributeRenamer" to rename "id" to "shp_id"

It is success on 2022.0.2 version

We can't see shp_id field in gpkg and the value in id field is kept

But in 2022.2.3 vesrion

It throw the error as

627 2023-2-28 13:03:03 | OGCGEOPACKAGE writer: OGCGEOPACKAGE writer: For feature type 'd_y_n40', primary key attribute 'id' has unsupported type 'mediumint'. Primary key must have type 'int,PrimaryKey'

 

Is any way can I fix it?

Thanks


4 replies

After I rename id to shp_id I get the following attribute mapping:

imageWhen I run this workbench I get a geopackage with the id attribute and without the shp_id attribute. The id attribute is filled with Null values since no attributes are mapped to it. You can check this by clicking on the attribute dropdown arrow on the writer.

 

Simplest fix is to go to the "User Attributes" tab on your geopackage writer and to change the mapping to Automatic. It will automatically add the new shp_id attribute with correct values.

However, even though the writer doesn't show an id field anymore, it will still create the id field with simple incrementing integer values, I think it does this because the geopackage format requires a field named "id".

 

Another fix is to change the attribute type of id from mediumint to int. This is better if you want to keep manual control over the attributes on the writer.

image.png 

Tested on Workbench version 2022.2.2

Also, in the future it would be better to ask questions like this about file transformations under the topic transformation. Under new to FME you might not get the attention of the right people.

Badge +1

Thanks for your suggestion.

But we are using dynamic mode for conversion. And we are using FME server

You mean version 2022.2.2 can't find the error message.

Let me try 2022.2.2

The attached is log and testing data

 

Badge +1

Here is the testing dataset

Reply