Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output DBF file field settings #16

Open
RolandNemeth opened this issue Jan 18, 2021 · 3 comments
Open

Output DBF file field settings #16

RolandNemeth opened this issue Jan 18, 2021 · 3 comments

Comments

@RolandNemeth
Copy link

RolandNemeth commented Jan 18, 2021

Is there a way to set for Write SHP the length and type of DBF fields? Right now it seems to output 255 characters long QStrings only, but I would need to be able to set for example 80 characters long Strings, or 10 characters long integer fields too. The other SHPExport component I have tried from Food4Rhino does this by specifying the field type like so: "Name;C;80" (name of row; type is Characters; length of input string) @nicoazel

@nicoazel
Copy link
Owner

nicoazel commented Jan 19, 2021

Hi Roland,
Implementing a feature like this would certainly be valuable, and has been mentioned by others. I have put some time into implementing automatic type identification and believe there is something functioning in one of the development branches for string, long, and float, but it has been a while since I have looked at the code.

I think your suggestion to provide more detailed parameters for the fields is a good one, and probably makes more sense from a GIS standpoint than auto identifying type.

I think many users are primarily interested in migrating geometry to GIS over additional field information so perhaps the functionality could default to text unless otherwise denoted in the field with a key like ';' semicolon as you mention. I'm not sure all users would be familiar enough with .shp data tables to set type in all instances, so some default is probably needed.

The plugin used Dot.Spatial and implements fields on a FeatureSet(fs) with:
fs.DataTable.Columns.Add(new DataColumn(field, typeof(''yourtype')));
So it should be easy to make this update if users do the legwork of identify field type.

I'm not sure if dot.spatial supports character length or even what data types it supports. Perhaps type specification is at users own risk? Either way this looks easy to implement and will be put on the TODO. Currently eta = infinity so pull requests on this are welcome.

@nicoazel
Copy link
Owner

So it was pretty easy to add type specification as mentioned above, but not in as robust a fashion as I might have hoped.

What I was able to get working pretty quickly is a type specification that is dependant on .net types. These do not align with dot.spatial/shp types 1:1 and it appears that dot.spatial has an internal automatic mapping of .net types, you can see my type testing below:

Imgur
Imgur
Imgur

NoticeBoolean => Short and Char => Text but is empty in the table.
Either way, this seems to be a good improvement. With a little more time it may be worth mapping types to simpler keys than needing to write out System. of .net built-in types.

I've posted a new version to the docs for download

@RolandNemeth
Copy link
Author

Hi, thanks for making this change, I had the chance to revisit this topic now, and your changes were immensely useful! The type character length was indeed not taken into account, but that caused no problems with the proper shp model creation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants