The following information is of particular relevance in terms of storing geodata data as attributes, which I could never get right before:
- C is ASCII characters
- N is a double precision integer limited to around 18 characters in length
- D is for dates in the YYYYMMDD format, with no spaces or hyphens between the sections
- F is for floating point numbers with the same length limits as N
- L is for logical data which is stored in the shapefile's attribute table as a short integer as a 1 (true) or a 0 (false). The values it can receive are 1, 0, y, n, Y, N, T, F or the python builtins True and False
Each of these datatypes is stored in an attribute created by pyshp using the code:
Where the two numbers are the length and the precision of the numerical value being stored. These are not needed for integers and non numeric datatypes, but a length of 1 is needed for logical data.
I have written a small code sample which creates data from lists to show the different datatypes being used correctly in pyshp to create points:
I have written a small code sample which creates data from lists to show the different datatypes being used correctly in pyshp to create points:
Hopefully I will have time soon to write up examples for polygons and lines and more complex use cases of pyshp.
No comments:
Post a Comment