I'm exporting geometry with attached text attributes from oracle database to esri shapefile format (.shp) with Java and Geotools library.
Attribute columns in our database have names with more than 10 characters, and Geotools forces to truncate them. I understand that it's due to .shp or .dbf files specification.
I can workaround this, by creating some simple txt file with "shrtname"="The full and long name", but obviously it won't be understand and imported by any other software than ours.
Is there official way to do the mapping from short field names to long full-text names?
For example, xml file next to all other .shp .dbf .shx files.
Answer
Sorry, the answer is no. You have to roll out your own field mapper and only software that uses your mapper will understand it. You could use other formats that do not have this limitation though (e.g. file geodatabase, spatialite, etc).
Some word of advice about the workarounds from personal experience.
When people choose shapefiles (and insist on them) as their main format, it is usually chosen for interoperability - think of it as adhering to a spec. If you choose to roll your own field mapper, you are basically doing quite the opposite - since you are doing things outside of a spec - you have created your "extended spec".
Have I done this in the past? Yes. And it most certainly always turns to more of a pain than actually solving a problem because every time you try to open the shapefiles into anything else that can read/write shapefiles, you end up with a table with a whole bunch of hard to understand fields.
At that point, I would ask you, why are you using shapefiles? Either come up with a workflow solution that sticks with the shapefile spec and its limitations, or change file formats. Everything else is just a recipe for headaches.
No comments:
Post a Comment